11

I have a <form> like this all the times.

.. raw:: html

    <form action="txmt://open/?url=file:///Users/smcho/smcho/works/prgtask/ni/gtest_boost_options/readme.txt">
    <button type="submit">Edit</button>
    </form>

Is there any macro or equivalent in reStructuredText so that I can get the same result, for example?

.. form :: /Users/smcho/smcho/works/prgtask/ni/gtest_boost_options/readme.txt
Chris
  • 44,602
  • 16
  • 137
  • 156
prosseek
  • 182,215
  • 215
  • 566
  • 871
  • Not for this question but for math then MathJax's `\newcommand` can be used as usual. Not usable in this case though. // Defining new role is also an option and does not require taking a newline: https://web.archive.org/web/20221206221128/https://doughellmann.com/posts/defining-custom-roles-in-sphinx/ // https://www.sphinx-doc.org/en/master/development/tutorials/helloworld.html – user202729 Jan 05 '23 at 16:37
  • There's also substitution: https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#cross-referencing-syntax – user202729 Apr 18 '23 at 06:16

2 Answers2

5

You could implement your own "form" directive in python. For instructions on how to do that, see http://docutils.sourceforge.net/docs/howto/rst-directives.html

Karl Bartel
  • 3,244
  • 1
  • 29
  • 28
0

You can use any template engine to generate your restructured text, and that gives you macros, loops, and much more. It will require some effort at the beginning, but it should not be terribly hard.

Roberto Alsina
  • 782
  • 4
  • 8