diff options
| author | nsfisis <nsfisis@gmail.com> | 2022-12-23 23:27:09 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2023-03-06 01:46:04 +0900 |
| commit | 88ba6cfe220216f371f8756921059fac51a21262 (patch) | |
| tree | f272db2a0a3340f103df6618f19a101e65941b37 /lib/extensions/section_id_validator.rb | |
| parent | 8f988a6e899aed678406ddfac1be4ef105439274 (diff) | |
| download | blog.nsfisis.dev-88ba6cfe220216f371f8756921059fac51a21262.tar.gz blog.nsfisis.dev-88ba6cfe220216f371f8756921059fac51a21262.tar.zst blog.nsfisis.dev-88ba6cfe220216f371f8756921059fac51a21262.zip | |
AsciiDoc to DocBook
Diffstat (limited to 'lib/extensions/section_id_validator.rb')
| -rw-r--r-- | lib/extensions/section_id_validator.rb | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/lib/extensions/section_id_validator.rb b/lib/extensions/section_id_validator.rb deleted file mode 100644 index 2ad496c..0000000 --- a/lib/extensions/section_id_validator.rb +++ /dev/null @@ -1,29 +0,0 @@ -module Nuldoc - module Extensions - class SectionIdValidator < Asciidoctor::Extensions::TreeProcessor - def process(doc) - errors = [] - (doc.find_by(context: :section) {_1.level > 0}).each do |section| - errors << validate_section(section) - end - error_message = errors.compact.join("\n") - unless error_message.empty? - raise "SectionIdValidator (#{doc.attributes['source-file-path']}):\n#{error_message}" - end - end - - private - - def validate_section(section) - id = section.id - unless id - return "Section '#{section.title}': each section MUST have an id." - end - unless id.match?(/\A[-0-9a-z]+\z/) - return "Section '#{section.title}' (##{id}): section id MUST consist of either hyphen, digits or lowercases." - end - nil - end - end - end -end |
