62 lines
1.9 KiB
Diff
62 lines
1.9 KiB
Diff
|
From 74c506e7c0b04c9aac242afc08cd6731bea5992a Mon Sep 17 00:00:00 2001
|
||
|
From: Christoph Reiter <reiter.christoph@gmail.com>
|
||
|
Date: Wed, 19 Dec 2018 22:17:16 +0100
|
||
|
Subject: [PATCH] docwriter: Support markdown 3.x. Fixes #250
|
||
|
|
||
|
---
|
||
|
giscanner/docwriter.py | 17 ++++++++++++++---
|
||
|
1 file changed, 14 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py
|
||
|
index a29ba374..dae2ca9e 100644
|
||
|
--- a/giscanner/docwriter.py
|
||
|
+++ b/giscanner/docwriter.py
|
||
|
@@ -34,7 +34,6 @@ import tempfile
|
||
|
from xml.sax import saxutils
|
||
|
from mako.lookup import TemplateLookup
|
||
|
import markdown
|
||
|
-from markdown.extensions.headerid import HeaderIdExtension
|
||
|
|
||
|
from . import ast, xmlwriter
|
||
|
from .utils import to_underscores
|
||
|
@@ -66,6 +65,18 @@ language_mimes = {
|
||
|
}
|
||
|
|
||
|
|
||
|
+def get_headerid_ext():
|
||
|
+ try:
|
||
|
+ from markdown.extensions.headerid import HeaderIdExtension
|
||
|
+ except ImportError:
|
||
|
+ # markdown 3.x
|
||
|
+ from markdown.extensions.toc import TocExtension
|
||
|
+ return TocExtension(toc_depth=0)
|
||
|
+ else:
|
||
|
+ # markdown 2.x
|
||
|
+ return HeaderIdExtension(forceid=False)
|
||
|
+
|
||
|
+
|
||
|
def make_page_id(node, recursive=False):
|
||
|
if isinstance(node, ast.Namespace):
|
||
|
if recursive:
|
||
|
@@ -1175,7 +1186,7 @@ class DevDocsFormatterGjs(DocFormatterGjs):
|
||
|
'markdown.extensions.fenced_code',
|
||
|
'markdown.extensions.nl2br',
|
||
|
'markdown.extensions.attr_list',
|
||
|
- HeaderIdExtension(forceid=False)
|
||
|
+ get_headerid_ext(),
|
||
|
])
|
||
|
|
||
|
def format_function_name(self, func):
|
||
|
@@ -1263,7 +1274,7 @@ class DevDocsFormatterGjs(DocFormatterGjs):
|
||
|
'markdown.extensions.fenced_code',
|
||
|
'markdown.extensions.nl2br',
|
||
|
'markdown.extensions.attr_list',
|
||
|
- HeaderIdExtension(forceid=False)
|
||
|
+ get_headerid_ext(),
|
||
|
])
|
||
|
|
||
|
def format_in_parameters(self, node):
|
||
|
--
|
||
|
2.18.1
|
||
|
|