Update md_browser to work with python-markdown v3.
Perhaps no one has tried to use this tool in a long time? In any case,
it wasn't working for me locally on Windows; this fixes it.
Bug: none
Change-Id: Iee762a62e7c1e4998c3dcc0fd6ca7d20ede664f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4114622
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1084509}
NOKEYCHECK=True
GitOrigin-RevId: 3f58d92bdcde9e3647a4e2346c995bc4c00a7f0c
diff --git a/gitiles_autolink.py b/gitiles_autolink.py
index 54bd9aa..7077e22 100644
--- a/gitiles_autolink.py
+++ b/gitiles_autolink.py
@@ -23,11 +23,12 @@
class _GitilesSmartQuotesExtension(Extension):
- """Add Gitiles' simpler linkifier to Markdown."""
+ """Add Gitiles' simpler linkifier to Markdown, with a priority just higher
+ than that of the builtin ''autolink''."""
def extendMarkdown(self, md):
- md.inlinePatterns.add('gitilesautolink',
- AutolinkInlineProcessor(AUTOLINK_RE, md), '<autolink')
+ md.inlinePatterns.register(AutolinkInlineProcessor(AUTOLINK_RE, md),
+ 'gitilesautolink', 122)
def makeExtension(*args, **kwargs):
diff --git a/gitiles_ext_blocks.py b/gitiles_ext_blocks.py
index 23fbcb0..7d42c13 100644
--- a/gitiles_ext_blocks.py
+++ b/gitiles_ext_blocks.py
@@ -12,8 +12,8 @@
from markdown.blockprocessors import BlockProcessor
from markdown.extensions import Extension
-from markdown.util import etree
import re
+import xml.etree.ElementTree as etree
class _GitilesExtBlockProcessor(BlockProcessor):
@@ -73,12 +73,12 @@
class _GitilesExtBlockExtension(Extension):
- """Add Gitiles' extended blocks to Markdown."""
+ """Add Gitiles' extended blocks to Markdown, with a priority higher than the
+ highest builtin."""
def extendMarkdown(self, md):
- md.parser.blockprocessors.add('gitilesextblocks',
- _GitilesExtBlockProcessor(md.parser),
- '_begin')
+ md.parser.blockprocessors.register(_GitilesExtBlockProcessor(md.parser),
+ 'gitilesextblocks', 101)
def makeExtension(*args, **kwargs):
diff --git a/gitiles_smart_quotes.py b/gitiles_smart_quotes.py
index 88f42ec..80003fa 100644
--- a/gitiles_smart_quotes.py
+++ b/gitiles_smart_quotes.py
@@ -28,12 +28,13 @@
class _GitilesSmartQuotesExtension(Extension):
- """Add Gitiles' smart quotes to Markdown."""
+ """Add Gitiles' smart quotes to Markdown, with a priority just higher than
+ that of the builtin 'em_strong'."""
def extendMarkdown(self, md):
- md.inlinePatterns.add('gitilessmartquotes',
- _GitilesSmartQuotesPattern(r"""(['"])([^\2]+)\2"""),
- '<em_strong')
+ md.inlinePatterns.register(
+ _GitilesSmartQuotesPattern(r"""(['"])([^\2]+)\2"""),
+ 'gitilessmartquotes', 61)
def makeExtension(*args, **kwargs):