Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing '.md' strings from template files breaks some URLs #45

Open
clnsmth opened this issue Dec 7, 2022 · 4 comments
Open

Removing '.md' strings from template files breaks some URLs #45

clnsmth opened this issue Dec 7, 2022 · 4 comments
Labels
bug Bug

Comments

@clnsmth
Copy link
Collaborator

clnsmth commented Dec 7, 2022

In content-x, content creators use relative links between markdown templates to simulate navigation among cross-referenced web pages. Before releasing new content, the relative links are converted from the GitHub context, to the web-x context. One step in this process is the removal of '.md' strings from template file contents. See:

md = md.replace(".md", "")

This is all fine and good until a markdown document is part of the target URL, in which case build.py strips the '.md' and web-x readers get a 404 when clicking on the link.

I was unsuccessful in attempts at solving this issue via regex with a backwards looking conditional (i.e. don't remove '.md' when part of a URL).

Other ideas?

@servilla
Copy link
Collaborator

servilla commented Dec 7, 2022

Is there an example of a template file containing a URL with an embedded markdown file reference we may use as a test case?

@servilla
Copy link
Collaborator

servilla commented Dec 7, 2022

One thought is to use a character entity encoding for the dot "." in the .md string so the replace function does not find it. It's a bit kludgy, but could/should work.

@servilla
Copy link
Collaborator

servilla commented Dec 7, 2022

In the URL you would replace . with %2E, so the markdown extension would transform from .md to %2Emd. This should be an acceptable encoding for URLs and obfuscate the .md to the replace function.

clnsmth added a commit to PASTAplus/content-x that referenced this issue Dec 7, 2022
@clnsmth
Copy link
Collaborator Author

clnsmth commented Dec 7, 2022

Nice @servilla. The %2E kludge works.

For an example, see this news article, specifically the hyperlinked "COUNTER Code of Practice for Research Data in Repositories".

I've noted this work around in the content-x contributing guidelines under the "Formatting and style" section.

Call this issue "closed" for now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug
Projects
Status: ToDo
Development

No branches or pull requests

2 participants