Sha256: 3ed4a4cc51870dd18c0a7b034a203620e3c3c5586594ee0b7cb468dded1e5e80
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true require "asciidoctor/standoc/base_structured_text_preprocessor" module Asciidoctor module Standoc class Yaml2TextPreprocessor < BaseStructuredTextPreprocessor # search document for block `yaml2text` # after that take template from block and read file into this template # example: # [yaml2text,foobar.yaml] # ---- # === {item.name} # {item.desc} # # {item.symbol}:: {item.symbol_def} # ---- # # with content of `foobar.yaml` file equal to: # - name: spaghetti # desc: wheat noodles of 9mm diameter # symbol: SPAG # symbol_def: the situation is message like spaghetti at a kid's # # will produce: # === spaghetti # wheat noodles of 9mm diameter # # SPAG:: the situation is message like spaghetti at a kid's meal def initialize(config = {}) super @config[:block_name] = "yaml2text" end protected def content_from_file(document, file_path) YAML.safe_load( File.read(relative_file_path(document, file_path), encoding: "UTF-8"), [Date, Time]) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
metanorma-standoc-1.6.0 | lib/asciidoctor/standoc/yaml2_text_preprocessor.rb |