PlantumlExtensions
Extension methods for PlantUML diagram rendering via Amg.Plantuml. Provides simplified API for converting PlantUML markup to image files.
public static class PlantumlExtensions
1. Methods
1.1. CreateLocalRenderer(string)
Creates a local PlantUML renderer instance. Requires Java and plantuml.jar to be available on the system.
public static IPlantuml CreateLocalRenderer(string jarPath = null)
| Name | Type | Description |
|---|---|---|
jarPath |
string |
Optional path to plantuml.jar. If |
Returns: IPlantuml — A disposable IPlantuml renderer.
1.2. IsValidPlantumlMarkup(string)
Validates that the given string is syntactically a PlantUML diagram (starts with @startuml and ends with @enduml).
public static bool IsValidPlantumlMarkup(string markup)
| Name | Type | Description |
|---|---|---|
markup |
string |
The PlantUML markup string to validate. |
Returns: bool — true if the markup has valid start/end delimiters.
1.3. WithCaching(IPlantuml, string)
Creates a cached PlantUML renderer that avoids re-rendering identical diagrams.
public static IPlantuml WithCaching(this IPlantuml renderer, string cacheDirectory = null)
| Name | Type | Description |
|---|---|---|
renderer |
IPlantuml |
The underlying renderer to cache. |
cacheDirectory |
string |
Optional cache directory path. |
Returns: IPlantuml — A disposable cached IPlantuml renderer.
1.4. WrapInPlantuml(string)
Wraps raw diagram content in @startuml / @enduml delimiters if they are not already present.
public static string WrapInPlantuml(string content)
| Name | Type | Description |
|---|---|---|
content |
string |
The diagram body (e.g. |
Returns: string — A complete PlantUML markup string with delimiters.