Module: AsciidoctorExtensions::PlantUmlPreprocessor
- Defined in:
- lib/asciidoctor/extensions/asciidoctor_kroki/preprocess.rb
Overview
Resolves PlantUML !include directives (and friends) in diagram text before it is sent to
the Kroki server, mirroring the JavaScript/Node.js extension's preprocessor (src/preprocess.js)
so both language bindings behave the same way. See http://plantuml.com/en/preprocessing.
Unlike the JS extension (which also supports Antora resource IDs and a pluggable virtual filesystem), this Ruby port only needs to resolve plain local paths and http(s) URLs, since the Ruby gem is not used with Antora. rubocop:disable Metrics/ModuleLength
Constant Summary collapse
- PLANTUML_BLOCK_RX =
/@startuml\r?\n([\s\S]*?)\r?\n@enduml/.freeze
- INCLUDE_LINE_RX =
/^\s*!(include(?:_many|_once|url|sub)?)\s+(.*)/.freeze
Class Method Summary collapse
-
.preprocess(diagram_text, resource_path, include_paths, logger) ⇒ String
The diagram text with !include directives resolved.
Class Method Details
.preprocess(diagram_text, resource_path, include_paths, logger) ⇒ String
Returns the diagram text with !include directives resolved.
29 30 31 32 33 34 |
# File 'lib/asciidoctor/extensions/asciidoctor_kroki/preprocess.rb', line 29 def preprocess(diagram_text, resource_path, include_paths, logger) resource = resource_path ? parse_resource(resource_path) : { dir: '', path: nil } paths = include_paths.to_s.empty? ? [] : include_paths.split(::File::PATH_SEPARATOR) diagram_text = preprocess_includes(diagram_text, resource, [], [], paths, logger) (diagram_text) end |