Skip to content

Link hrefs and code styling#95

Merged
andysteadbbc merged 4 commits intobbc:mainfrom
paulbrimicombe:link-hrefs-and-code-styling
Oct 23, 2024
Merged

Link hrefs and code styling#95
andysteadbbc merged 4 commits intobbc:mainfrom
paulbrimicombe:link-hrefs-and-code-styling

Conversation

@paulbrimicombe
Copy link
Copy Markdown
Contributor

🧐 What?

This PR (naughtily) makes two changes (if you'd much rather have two separate PRs do let me know!):

Code block formatting

Format <code> blocks more consistently. Currently the styling is inconsistent if the <code> block is in a paragraph or in some kind of list. Here's an example (seen on this page):

image

Root links in <link> tags

GitHub supports links relative to the root of the repository (e.g. /README.md maps to the top level readme file regardless of the location of the file it's in). It's sometimes handy to be able to add custom styles for morty-docs files. This is currently possible by adding a <link> tag:

<link rel="stylesheet" type="text/css" href="./app.css" />

This gets quite painful quite quickly if there are lots of MarkDown files in lots of sub-folders (e.g. these files since you have to continually adjust the relative path in the href.

It would be nicer if we supported links relative to the root of the repository in <link> tags as well as <a> tags:

This would be transformed to `/morty-docs/some-repo/app.css`
<link rel="stylesheet" type="text/css" href="/app.css" />

🛠 How

  • Changed the code CSS selector to use :not(pre) instead of p to target all code blocks not in a pre
  • Added a transformer similar to the addBasePathToRootLinks transformer to handle link tag href attributes that are relative to the root of the repository

@andysteadbbc andysteadbbc merged commit 528b635 into bbc:main Oct 23, 2024
@paulbrimicombe paulbrimicombe deleted the link-hrefs-and-code-styling branch October 28, 2024 08:59
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