kit-doc edge
MarkdownPreprocessor
module
Kit::Doc::Services::MarkdownPreprocessor
View Source
Kit::Doc::Services::MarkdownPreprocessor
Basic markdown preprocessing.
Adds variable substitution when generating Kit::Doc documentation, while staying compatible with Github markdown previews.
This is particularly helpful for versionned link references in Guides.
Link to this section Summary ⚠️ Private APIs are currently hidden.
Link to this section Class methods 2
Link to this method
.preproc_conditionals(content:, variables:, preproc_regex: PREPROC_REGEX)
View SourceReplace static content: by dynamic one hidden in html comments.
Also calls preproc_variables to resolve dynamic values in preprocessing comments.
Examples
irb> preproc_conditionals({
content: <<~TEXT,
<!--pp -->
[Doc - GitHub Link](https://docs.rubykit.org/kit/edge)
<!-- { [Doc - Kit Link](https://docs.rubykit.org/kit/$VERSION) } pp-->
TEXT
variables: { VERSION: 'v0.1.0' }
})
[:ok, processed_content: '[Doc - Kit Link](https://docs.rubykit.org/kit/v0.1.0)']
Link to this method
.preproc_variables(content:, variables: {}, variables_regex: VARIABLES_REGEX)
View SourceLink to this section Constants 2
Simple regex to identify preprocessing comments.
Examples
<!--pp -->
[Doc - GitHub Link](https://docs.rubykit.org/kit/edge)
<!-- { [Doc - Kit Link](https://docs.rubykit.org/kit/$VERSION) } pp-->
Will generate a match from `<!--pp` to `pp-->`,
with the content inside `{}` captured in a group named `prepoc_content`:
[Doc - Kit Link](https://docs.rubykit.org/kit/$VERSION)
The regex simply match