diff options
| author | Shahbaz Youssefi <ShabbyX@gmail.com> | 2023-04-02 02:57:06 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-02 00:57:06 -0600 |
| commit | e1646ba4e98a715b56fe7ddae77e6f43a333a615 (patch) | |
| tree | ef83107979ae1da5c25b22731fabd22b943cb793 /docs/modules/api/pages | |
| parent | a26ab8080dfaff33871107ad73a455c4255063d6 (diff) | |
Clarify in docs that source_location is not tracked by default (PR #4416)
Diffstat (limited to 'docs/modules/api/pages')
| -rw-r--r-- | docs/modules/api/pages/sourcemap.adoc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/modules/api/pages/sourcemap.adoc b/docs/modules/api/pages/sourcemap.adoc index ed32891f..2bfb1b76 100644 --- a/docs/modules/api/pages/sourcemap.adoc +++ b/docs/modules/api/pages/sourcemap.adoc @@ -46,6 +46,26 @@ Here's an example of how to enable the sourcemap using the API: doc = Asciidoctor.load_file 'doc.adoc', safe: :safe, sourcemap: true ---- +Extensions can enable the sourcemap as such: + +[,ruby] +---- +class Asciidoctor::Document + attr_writer :sourcemap unless method_defined? :sourcemap= +end + +# A preprocessor that enables the sourcemap feature if not +# already enabled via the API. +Asciidoctor::Extensions.register do + preprocessor do + process do |doc, reader| + doc.sourcemap = true + nil + end + end +end +---- + Now that the sourcemap is enabled, you can access the source location of the block elements in the parsed document. == Use the sourcemap |
