Comments (9)
You can have a look at https://www.sphinx-doc.org/en/master/development/tutorials/todo.html to see a little example.
The link you posted above ( https://github.com/ankita240796/docs/blob/f57ebfbb3dc82b256334efbf6a697ef612b36890/video.py ) is another example.
Inside a Sphinx extension, you define a new directive that will create a new type of node inside the document tree. Thus, you also define a new node class in the extension. Of course, you now have to explain how you would transform this new type of node into HTML, Latex or, here, Markdown. So, you write several "functions" that can transform this type of node into an output format. These functions will be dynamically weaved into a node visitor as visit / depart methods (so you need a visit function and a depart function and you have to be compliant with the node visitor internal behaviour). When you register the new type of node in the Sphinx application with the add_node
method, you also give the visit / depart functions for each format you want to support.
In the "todo" tutorial, this is what is done for the todo
node. In the "video" example, this is also what is done for the video_node
.
from sphinx-markdown-builder.
@Tilix4 could you give a more detailed example of what you are referring to?
from sphinx-markdown-builder.
Hi @codejamninja , something like https://github.com/ankita240796/docs/blob/f57ebfbb3dc82b256334efbf6a697ef612b36890/video.py
This allows you to set a:
.. video:: /path/to/video.vid
:options:
As we create html content with directives, it could be nice that your builder takes directly the raw html content to insert it in MD ouput (AFAIK it's fully supported) before designing a custom export.
from sphinx-markdown-builder.
Want to take a stab at it? The code to build it up is in this file.
from sphinx-markdown-builder.
I'll look into it, do you have any idea about the name of the function to handle any directive?
visit_directive()
?
from sphinx-markdown-builder.
I do not. I have not worked with custom directives.
from sphinx-markdown-builder.
I've just proposed a PR that will allow the addition of custom functions for transforming your custom nodes when you define your extension. I don't know if it will solve all the problems described in this issue but, in my opinion, it is a first step.
from sphinx-markdown-builder.
I just accepted the merge request. I'll release a new version this week.
from sphinx-markdown-builder.
That seems nice but I don't really get all the possibilities? Will you provide some code examples?
from sphinx-markdown-builder.
Related Issues (20)
- Use version ranges instead of pinning exact versions HOT 3
- Literalinclude has too many newlines.
- Add option to change markdown delimiters. HOT 1
- custom node support HOT 5
- ModuleNotFoundError: No module named 'sphinx_markdown_parser' HOT 2
- Documetation outdated HOT 2
- update requirements file HOT 2
- AttributeError: type object 'MarkdownBuilder' has no attribute 'supported' HOT 19
- README typo? HOT 2
- Directive 'figure' is not supported HOT 4
- Missing plenty of nodes (notes, admonitions, labels, code-block, hlist, centered, glossary...) HOT 4
- Tables are not supported HOT 8
- Misalignment of elements for nested lists HOT 3
- Several errors building to markdown Godot-Engine manual HOT 2
- Apply to be Co-Maintainer of sphinx-markdown-builder HOT 5
- Filter out yapf from install_requires in setup.py HOT 1
- Lists have too much blank space HOT 4
- Add `singlemarkdown` mode to help with internal project development HOT 3
- Linked file extension HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sphinx-markdown-builder.