-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Transforms and coordiates * Auto-link glossary items * Add wording related to the render stack * Fix build * 3x3 Matrices * Explain transforms a bit better * Mention untransformed (0, 0)
- Loading branch information
Showing
7 changed files
with
229 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Glossary | ||
|
||
local coordinates | ||
: The local coordinate system is the coordinate system of the current | ||
group or layer, with the X coordinate increasing towards the right | ||
and the Y coordinate increasing towards the bottom. | ||
Without any transforms, the point $(0, 0)$ corresponds with the top-left | ||
corner of the viewport. | ||
render stack | ||
: A render stack is a list if rendering primitive to be drawn in inverse | ||
stack order. A render stack can contain child stacks. | ||
stacking order | ||
: The order in which objects appear in the [[render stack]]. | ||
collected shapes | ||
: When collecting shapes for a rendering operation, implementations MUST | ||
traverse the [[render stack]] in reverse order. | ||
All {link:shapes/shape:Shapes} encountered in the stack traversal MUST | ||
be included, until the beginning of the stack is reached or a {link:shapes/modifier} | ||
is encountered. If a {link:shapes/modifier} is found, it MUST be applied to | ||
its own _collected shapes_ and the output added to the shape collection. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import xml.etree.ElementTree as etree | ||
|
||
from markdown.treeprocessors import Treeprocessor | ||
from markdown.inlinepatterns import InlineProcessor | ||
from markdown.extensions import Extension | ||
from markdown.extensions import toc | ||
|
||
from lottie_markdown import get_url | ||
|
||
|
||
class TocDefListTreeProcessor(Treeprocessor): | ||
old_nest = toc.nest_toc_tokens | ||
|
||
def __init__(self, md): | ||
super().__init__(md) | ||
self.extra_toc = [] | ||
# Patch toc.nest_toc_tokens to show glossary terms in the | ||
# table of contents (Hack) | ||
toc.nest_toc_tokens = self.patched_nest_toc_tokens | ||
|
||
def patched_nest_toc_tokens(self, toc_list): | ||
tl = TocDefListTreeProcessor.old_nest(toc_list + self.extra_toc) | ||
self.extra_toc = [] | ||
return tl | ||
|
||
def run(self, root): | ||
self.extra_toc = [] | ||
|
||
term: etree.Element | ||
for term in root.findall(".//dt"): | ||
if "id" not in term.attrib: | ||
text = toc.unescape(toc.stashedHTML2text(toc.get_name(term), self.md)) | ||
id = toc.slugify(text, "-") | ||
term.attrib["id"] = id | ||
link = etree.Element("a") | ||
for child in term: | ||
term.remove(child) | ||
link.append(child) | ||
link.text = term.text | ||
term.text = "" | ||
term.append(link) | ||
link.attrib["href"] = "#" + id | ||
self.extra_toc.append({ | ||
"level": 2, | ||
"id": id, | ||
"name": text | ||
}) | ||
|
||
|
||
class GlossaryLink(InlineProcessor): | ||
def __init__(self, md): | ||
super().__init__(r'\[\[([^\]\|]+)(?:\|([^\]]+))?\]\]', md) | ||
|
||
def handleMatch(self, match, data): | ||
link = etree.Element("a") | ||
title = match.group(1) | ||
id = toc.slugify(title, "-") | ||
link.attrib["href"] = get_url(self.md, "specs/glossary.md", id) | ||
link.text = match.group(2) or title | ||
return link, match.start(0), match.end(0) | ||
|
||
|
||
class TocDefListExtension(Extension): | ||
def extendMarkdown(self, md): | ||
md.registerExtension(self) | ||
md.treeprocessors.register(TocDefListTreeProcessor(md), "toc_deflist", 175) | ||
md.inlinePatterns.register(GlossaryLink(md), "glossary_link", 175) | ||
|
||
|
||
def makeExtension(**kwargs): | ||
return TocDefListExtension(**kwargs) |