Skip to content

Conversation

@gmilde
Copy link
Contributor

@gmilde gmilde commented May 27, 2025

In Moin 1.9, hyperlink references without target default to items of the local wiki. Port this feature to Moin 2.0.
Adapt to the new program structure:

Define a "transform" that resolves hyperlink references without a matching target.

Define a custom parser to register the "transform". (The Writer component is not used in Moin 2.0)

Call docutils.core.publish_doctree() with the custom parser. Also specify a "source_path" identifier (for improved error messages).

In Moin 1.9, hyperlink references without target default to items of
the local wiki. Port this feature to Moin 2.0.
Adapt to the new program structure:

Define a "transform" that resolves hyperlink references without
a matching target.

Define a custom parser to register the "transform".
(The `Writer` component is not used in Moin 2.0)

Call `docutils.core.publish_doctree()` with the custom parser.
Also specify a "source_path" identifier (for improved error messages).
@gmilde
Copy link
Contributor Author

gmilde commented May 27, 2025

TODO: Update documentation. How?
Suggestion:

diff --git a/src/moin/help/help-en/rst.data b/src/moin/help/help-en/rst.data
index cee5fd96..26975935 100644
--- a/src/moin/help/help-en/rst.data
+++ b/src/moin/help/help-en/rst.data
@@ -134,11 +134,12 @@ Within the rst syntax:
  * a link that begins with a namespace like ``http:users/Home`` links to the Home item in the target namespace
  * a link like ``http:../sibling`` links to a sibling of the current item
 
-.. _myanchor:
-
 +-----------------------------+-------------------------------------+------------------------------------------------------------+
 |Markup                       |Result                               |Comment                                                     |
 +=============================+=====================================+============================================================+
+| ``link_``                   |link_                                |_`link` to a heading or anchor in this item or an item      |
+|                             |                                     |in the default namespace of this wiki                       |
++-----------------------------+-------------------------------------+------------------------------------------------------------+
 | ``http:Home``               |http:Home                            |link to an item in the default namespace of this wiki       |
 +-----------------------------+-------------------------------------+------------------------------------------------------------+
 | ```Home2 <http:Home>`_``    |`Home2 <http:Home>`_                 |fancy link to an item in the default namespace of this wiki |
@@ -155,14 +156,16 @@ Within the rst syntax:
 +-----------------------------+-------------------------------------+------------------------------------------------------------+
 | ```Internal Links`_``       |`Internal Links`_                    |link to a heading with embedded blanks                      |
 +-----------------------------+-------------------------------------+------------------------------------------------------------+
-| ``.. _myanchor:``           |                                     |create anchor, real anchor is above this table              |
+| ``_`anchor:```              |_`anchor`                            |inline anchor, the id is derived from the text.             |
++-----------------------------+-------------------------------------+------------------------------------------------------------+
+| ``.. _myanchor:``           |.. _myanchor:                        |invisilble anchor for the next (block-level) element        |
 +-----------------------------+-------------------------------------+------------------------------------------------------------+
 | ``myanchor_``               |myanchor_                            |link to above anchor                                        |
 +-----------------------------+-------------------------------------+------------------------------------------------------------+
 
 **Notes:**
  - If this page was created by Sphinx, none of the above internal link examples work correctly.
- - The ".. _myanchor:" directive must begin in column one.
+ - The ".. _myanchor:" directive does not work inline.
  - Section titles (or headings) automatically generate hyperlink targets (the title
    text is used as the hyperlink name).

@gmilde
Copy link
Contributor Author

gmilde commented May 27, 2025

This patch is one part of a solution for issue #1680

@RogerHaase RogerHaase merged commit b0d25c1 into moinwiki:master Jun 4, 2025
8 checks passed
@RogerHaase
Copy link
Member

Thanks for helping!

The rst docs are in docs/user/rest.rst. Edit with your favorite editor, save, run /m docs to update the local docs. Restart the server, view the changes at http://127.0.0.1:5000/help-en/rst

Commit when you are ready.

@gmilde gmilde deleted the rst-wiki-links branch June 5, 2025 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants