]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tools: (asciidoctor-unicodeconverter) fix up name section with dash
authorThomas Weißschuh <thomas@t-8ch.de>
Fri, 5 May 2023 21:33:14 +0000 (23:33 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Sat, 6 May 2023 04:47:42 +0000 (06:47 +0200)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
tools/asciidoctor-unicodeconverter.rb

index acb1c8b805185bac3669b1ff2afe284699d7f88c..7435ed5ffae572e5f785ee833925989da8a0a103 100644 (file)
@@ -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? '== '