freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master ea68f1c 3/4: [docmaker] Fix code section parsing.


From: Werner LEMBERG
Subject: [freetype2] master ea68f1c 3/4: [docmaker] Fix code section parsing.
Date: Fri, 8 Dec 2017 14:47:42 -0500 (EST)

branch: master
commit ea68f1c8d3e2815e2ca22ff83de1fdd26d07af49
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [docmaker] Fix code section parsing.
    
    Stuff like
    
      {
        <bla>
      }
    
    confused the parser, which incorrectly treated `<bla>' as a markup
    tag.
    
    * src/tools/docmaker/content.py (ContentProcessor::process_content):
    Apply `re_markup_tags' only outside of code sections.
---
 ChangeLog                     | 16 ++++++++++++++++
 src/tools/docmaker/content.py | 31 ++++++++++++++++++++++++-------
 2 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4949130..ee8663b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2017-12-08  Werner Lemberg  <address@hidden>
 
+       [docmaker] Fix code section parsing.
+
+       Stuff like
+
+         {
+           <bla>
+         }
+
+       confused the parser, which incorrectly treated `<bla>' as a markup
+       tag.
+
+       * src/tools/docmaker/content.py (ContentProcessor::process_content):
+       Apply `re_markup_tags' only outside of code sections.
+
+2017-12-08  Werner Lemberg  <address@hidden>
+
        New `ftdriver.h' file, covering all driver modules.
 
        This reduces redundancy and increases synergy; it also reduces the
diff --git a/src/tools/docmaker/content.py b/src/tools/docmaker/content.py
index 283d815..d432feb 100644
--- a/src/tools/docmaker/content.py
+++ b/src/tools/docmaker/content.py
@@ -453,15 +453,32 @@ class  ContentProcessor:
         markup_lines = []
         first        = 1
 
+        margin  = -1
+        in_code = 0
+
         for line in content:
-            found = None
-            for t in re_markup_tags:
-                m = t.match( line )
+            if in_code:
+                m = re_code_end.match( line )
+                if m and len( m.group( 1 ) ) <= margin:
+                    in_code = 0
+                    margin  = -1
+            else:
+                m = re_code_start.match( line )
                 if m:
-                    found  = string.lower( m.group( 1 ) )
-                    prefix = len( m.group( 0 ) )
-                    line   = " " * prefix + line[prefix:]   # remove markup 
from line
-                    break
+                    in_code = 1
+                    margin  = len( m.group( 1 ) )
+
+            found = None
+
+            if not in_code:
+                for t in re_markup_tags:
+                    m = t.match( line )
+                    if m:
+                        found  = string.lower( m.group( 1 ) )
+                        prefix = len( m.group( 0 ) )
+                        # remove markup from line
+                        line   = " " * prefix + line[prefix:]
+                        break
 
             # is it the start of a new markup section ?
             if found:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]