Skip to content

MyST does not link to anchors within non-auto-generated markdown or HTML files #564

@prescod

Description

@prescod

Describe the bug

context
When I do this:


Works: [b](c.html)
Does not work: [b](c.html#foo)

expectation
I expected two links.

bug
But instead only one link is created.

$ sphinx-build docs out

...
/private/tmp/mysttest/docs/index.md:3: WARNING: 'myst' reference target not found: c.html#foo
...

problem
This is a problem for people who need to link to anchors inside of HTML files.

Reproduce the bug

 CCI-39 ▶ tmp ❯ mysttest ▶ 12 ▶ % ▶ cat docs/index.md                 
# AAAAA

Works: [b](c.html)

Does not work: [b2](c.html#foo)
 CCI-39 ▶ tmp ❯ mysttest ▶ 12 ▶ % ▶ cat docs/conf.py                  
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
    "sphinx.ext.autodoc",
    "sphinx.ext.viewcode",
    "sphinx.ext.autosectionlabel",
    "myst_parser"  # ,
    #    "recommonmark"
]
 CCI-39 ▶ tmp ❯ mysttest ▶ 12 ▶ % ▶ cat docs/c.html                   
<a id="foo">Foo!</a>
 CCI-39 ▶ tmp ❯ mysttest ▶ 12 ▶ % ▶ rm -rf out ; sphinx-build docs out
Running Sphinx v4.5.0
making output directory... done
myst v0.17.1: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions=[], linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', disable_syntax=[], all_links_external=False, url_schemes=['http', 'https', 'mailto', 'ftp'], ref_domains=None, highlight_code_blocks=True, number_code_blocks=[], title_to_header=False, heading_anchors=None, heading_slug_func=None, html_meta=[], footnote_transition=True, substitutions=[], sub_delimiters=['{', '}'], words_per_minute=200)
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
reading sources... [100%] index                                                                                      
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index                                                                                       
/private/tmp/mysttest/docs/index.md:5: WARNING: 'myst' reference target not found: c.html#foo
generating indices... genindex done
writing additional pages... search done
copying downloadable files... [100%] c.html                                                                          
copying static files... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded, 1 warning.

The HTML pages are in out.

List your environment

sphinx-build --version            
sphinx-build 4.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionno fixed close conditionsyntaxdescisions on syntax formats

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions