[gobject-introspection/gnome-3-30] docwriter: Support markdown 3.x. Fixes #250
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/gnome-3-30] docwriter: Support markdown 3.x. Fixes #250
- Date: Wed, 26 Dec 2018 17:41:49 +0000 (UTC)
commit 74c506e7c0b04c9aac242afc08cd6731bea5992a
Author: Christoph Reiter <reiter christoph gmail com>
Date: Wed Dec 19 22:17:16 2018 +0100
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):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]