Coder Social home page Coder Social logo

Comments (9)

ocayrol avatar ocayrol commented on June 15, 2024 1

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.

clayrisser avatar clayrisser commented on June 15, 2024

@Tilix4 could you give a more detailed example of what you are referring to?

from sphinx-markdown-builder.

Tilix4 avatar Tilix4 commented on June 15, 2024

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.

clayrisser avatar clayrisser commented on June 15, 2024

Want to take a stab at it? The code to build it up is in this file.

https://github.com/codejamninja/sphinx-markdown-builder/blob/master/sphinx_markdown_builder/markdown_writer.py

from sphinx-markdown-builder.

Tilix4 avatar Tilix4 commented on June 15, 2024

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.

clayrisser avatar clayrisser commented on June 15, 2024

I do not. I have not worked with custom directives.

from sphinx-markdown-builder.

ocayrol avatar ocayrol commented on June 15, 2024

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.

clayrisser avatar clayrisser commented on June 15, 2024

I just accepted the merge request. I'll release a new version this week.

from sphinx-markdown-builder.

Tilix4 avatar Tilix4 commented on June 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.