Comments (8)
And the next question that still remains, is: How to go about creating a local (non-global) target that is specific to each document?
I'd want to be able to reference 1.md#target1 and 2.md#target1 - where each one is a different topic.
You can use: https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#syntax-header-anchors
from myst-parser.
Thanks for opening your first issue here! Engagement like this is essential for open source projects! ðĪ
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! ð
from myst-parser.
Does it work better with [link](/1.md#title1-target)
(without the leading dot)?
Moreover, no need for the anchor (title1-target)=
: [link](/1.md)
is enough.
BTW, please put your code into ``` ```
: otherwise, as Markdown code, it is rendered on these GitHub issues pages.
from myst-parser.
Thank you, @dbitouze. I will enclose the document in ``` as you suggested.
[link](/1.md#title1-target)
does not work because it is an absolute path, and not the correct reference to the relative path of the file.
Secondly, [link](/1.md)
will only link to the document itself and not a specific subsection in that file. The real goal is to be able to link to a specific subsection in another file. I was trying to make the example simple - but he intention was not conveyed clearly.
However, interestingly, I discovered that linking works if you don't use the file name at all (e.g. [link](#title-target)
). This will need the anchor link names to be unique across the entire documentation (i.e. I cannot use "title1-targtet" anywhere else in the entire set of documentation that I may be generating/writing).
Here are some more (hopefully clearer) examples, including an updated conf.py.
***** conf.py *****
project = 'test_blog'
copyright = '2023, test'
author = 'test'
extensions = [
'myst_parser',
]
myst_heading_anchors = 7
templates_path = ['_templates']
exclude_patterns = []
html_theme = 'alabaster'
html_static_path = ['_static']
myst_enable_extensions = [
"amsmath",
"attrs_block",
"attrs_inline",
"colon_fence",
"deflist",
"dollarmath",
"fieldlist",
"html_admonition",
"html_image",
"linkify",
"replacements",
"smartquotes",
"strikethrough",
"substitution",
"tasklist",
]
***** conf.py *****
***** 1.md *****
(title1-target)=
# Title-1
This is some text
---
{#another-target}
## Subtitle-2
Here's another line that we want to link to, but will cause a warning message to be thrown if referenced as ```(./1.md#another-target)```.
(yet-another-target)=
Linking to this line throws no warnings if you just reference it as ```(#yet-another-target)``` in another document.
Referencing it as ```(./1.md#yet-another-target)``` throws a warning.
***** 1.md *****
***** 2.md *****
# Title-2
More text and a [link](#title1-target)
Here's a link to a section in [another document](./1.md#another-target). This syntax throws a warning.
[This throws no warnings](#another-target)
Here's another example of linking to ```yet-another-target```
[Throws warning](./1.md#yet-another-target)
[No problem](#yet-another-target)
***** 2.md *****
Referencing (#title1-target), (#another-target) and (#yet-another-target)
directly, without being prefixed by ./1.md
works. But for these names to be unique, they cannot be used anywhere else in the documentation (plus, reading the raw markdown file provides no context that it's really 1.md that's being linked to).
from myst-parser.
I have the same problem with sphinx-build
(7.2.6), sphinx-intl
and myst-parser
(2.0.0). I've observed that when creating links that reference anchors in other Markdown files, the links are constructed. However, when there are multiple such links within a file, only the last anchor link URI seems to be applied for all occurences with xref_missing
. Warnings are logged, e.g.:
/docs/source/main.md:1:<translated>:1: WARNING: local id not found in doc 'test/test': 'bar' [myst.xref_missing]
/docs/source/main.md:1:<translated>:1: WARNING: local id not found in doc 'test/test': 'bar' [myst.xref_missing]
Please note that bar
appears two times in the logs, but I referenced foo
and bar
:
[foo](../test/test.md#foo) and [bar](../test/test.md#bar)
from myst-parser.
@lytn1ng: This is not an issue. It is a feature. Targets defined with ()=
are global.
from myst-parser.
Thank you,@n-peugnet.
However, it would be good to clarify this in the documentation too - because I certainly tried looking several times before creating this issue.
And the next question that still remains, is: How to go about creating a local (non-global) target that is specific to each document?
I'd want to be able to reference 1.md#target1 and 2.md#target1 - where each one is a different topic.
from myst-parser.
And the next question that still remains, is: How to go about creating a local (non-global) target that is specific to each document?
I'd want to be able to reference 1.md#target1 and 2.md#target1 - where each one is a different topic.You can use: https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#syntax-header-anchors
This works for me, thank you, @n-peugnet
from myst-parser.
Related Issues (20)
- Equation label of math not work before `make clean` when math_numfig=True HOT 7
- Support sphinx 7.3 - use default config value types HOT 2
- `end-before` parameter thinks it has no argument HOT 3
- More than one target found for 'myst' cross-reference [myst.xref_ambiguous] HOT 3
- $$ equation reference is not identified unless preceded by a blank line HOT 3
- no syntax to create line_block (hardbreak creates paragraph with raw linebreaks) HOT 4
- `## Heading 2` produces `<h1>Heading 2</h1>` HOT 4
- Issue on page /syntax/admonitions.html - In example, class should be space separated not comma HOT 3
- Include directive does not consider parser option HOT 2
- replacement of "." in headings for slugs HOT 1
- Test regressions with Sphinx 7.3.7 HOT 2
- Missing newline from doc HOT 5
- For v3.0.1: indented directive options no longer recognised HOT 7
- For v3.0.1: If the last directive option has an empty value then it is omitted HOT 5
- Add `:tag:` Option for Custom Equation Numbering in `{math}` Directives HOT 1
- Add warning for invalid footnotes reference (and unused definitions) HOT 3
- Add example config.yml entries for autodoc-2 HOT 1
- More Complete Info about Auto Documentation HOT 1
- Substitution in Block doesn't seem to work in Live Preview HOT 2
- Re-add support for \[, \], \(, and \) HOT 1
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 myst-parser.