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

Some links do not rendered in the PDF #1712

Closed
Remi-Gau opened this issue Feb 26, 2024 · 6 comments · Fixed by #1738
Closed

Some links do not rendered in the PDF #1712

Remi-Gau opened this issue Feb 26, 2024 · 6 comments · Fixed by #1738

Comments

@Remi-Gau
Copy link
Collaborator

Note that some links are not rendered in the pdf.

For example the link at the top of the genetic section:

[`UK biobank`](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)

I think this is because of the back tick in the square brackets.

Originally posted by @Remi-Gau in #1711 (comment)

@Remi-Gau Remi-Gau changed the title Some links do not rended in the PDF Some links do not rendered in the PDF Mar 20, 2024
@Remi-Gau
Copy link
Collaborator Author

Remi-Gau commented Mar 21, 2024

OK the solution to this one (so far)

The following won't be turned into a link during the pdd build
-   [`UK biobank`](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)
-   [UK biobank](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb) 

This will
[`UK biobank`](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)

@sappelhoff
Copy link
Member

interesting, thanks for investigating!

So we'd have to:

  1. in the PDF build, check if list items are links
  2. turn these selective lists that contain such items into non-lists

??

what about:

will this link render?
    -   A link follows: [`a link`](https://google.com)

@Remi-Gau
Copy link
Collaborator Author

OK I tried a bunch of things:


!!! example "Example datasets"

    The following example dataset with genetics data have been formatted using this specification
    and can be used for practical guidance when curating a new dataset.

    -   [`UK biobank`](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)
    -   foo bar [`UK biobank`](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)
    -   [UK biobank](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)

-   [`UK biobank`](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)
-   foo bar [`UK biobank`](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)
-   [UK biobank](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)

- [UK biobank](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)
- foo bar [UK biobank](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)

[`UK biobank`](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)

and I got this:

image

@sappelhoff
Copy link
Member

so the admonitions are the problem 🤔

don't get it though, as your script removes the admonition completely:

def remove_admonitions(
input_folder: str | Path, output_folder: str | Path, indent: str = None
):
if indent is None:
indent = INDENT
md_files = Path(input_folder).glob("**/*.md")
for file in md_files:
with open(file, "r", encoding="utf8") as f:
content = f.readlines()
output_file = Path(output_folder) / file.relative_to(input_folder)
output_file.parent.mkdir(parents=True, exist_ok=True)
print(f"processing: {file}\n to: {output_file}")
with open(output_file, "w", encoding="utf8") as f:
is_admonition = False
counter = 0
for line in content:
if any(line.startswith(x) for x in ADMONITION_DELIMITERS):
is_admonition = True
counter = 0
continue
# skip first line after admonition
if is_admonition and counter == 0:
counter += 1
continue
if not line.startswith(indent):
is_admonition = False
if is_admonition:
line = line.lstrip(indent)

@Remi-Gau
Copy link
Collaborator Author

let me test the script the blurb above

@Remi-Gau
Copy link
Collaborator Author

OK if I run the remove_admonition code on the blurb above it gives this

The following example dataset with genetics data have been formatted using this specification
and can be used for practical guidance when curating a new dataset.

    -   [`UK biobank`](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)
    -   foo bar [`UK biobank`](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)
    -   [UK biobank](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)

-   [`UK biobank`](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)
-   foo bar [`UK biobank`](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)
-   [UK biobank](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)

- [UK biobank](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)
- foo bar [UK biobank](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)

[`UK biobank`](https://github.com/bids-standard/bids-examples/tree/master/genetics_ukbb)

So my code is too silly... Will try to fix.

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 a pull request may close this issue.

2 participants