From: Thomas Weißschuh Date: Fri, 5 May 2023 21:33:14 +0000 (+0200) Subject: tools: (asciidoctor-unicodeconverter) fix up name section with dash X-Git-Tag: v2.39~32 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dcc187cc8431ae383d44444321125f0b11b51417;p=thirdparty%2Futil-linux.git tools: (asciidoctor-unicodeconverter) fix up name section with dash Signed-off-by: Thomas Weißschuh --- diff --git a/tools/asciidoctor-unicodeconverter.rb b/tools/asciidoctor-unicodeconverter.rb index acb1c8b805..7435ed5ffa 100644 --- a/tools/asciidoctor-unicodeconverter.rb +++ b/tools/asciidoctor-unicodeconverter.rb @@ -7,13 +7,20 @@ module UnicodeConverter AFTER_NAME_SECTION = 3 class Preprocessor < Asciidoctor::Extensions::Preprocessor + include Asciidoctor::Logging + def process document, reader lines = reader.read_lines state = BEFORE_NAME_SECTION + command = document.attributes['docname'].split('.', 2)[0] lines.map! do |line| if state == IN_NAME_SECTION line.sub! " \u2013 ", " - " line.sub! " \u2014 ", " - " + if line.start_with? command and not line.start_with? "#{command} - " + logger.warn "adding dash to name section of #{document.attributes['docfile']}" + line.sub! command, "#{command} - " + end end if line.start_with? '== '