-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add linkPrefixForNonMarkdownResources
to transform config
#76
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, small nits only otherwise LGTM 💪🏽
pkg/transform/testdata/mdox4.yaml
Outdated
- "testdata/test.md" | ||
- "testdata/teststatic" | ||
|
||
glueLink: "https://github.com/bwplotka/mdox/tree/main" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rethink the name.. maybe linkPrefixForNonMarkdownResources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
pkg/transform/transform.go
Outdated
@@ -296,6 +307,30 @@ func (r *relLinkTransformer) TransformDestination(ctx mdformatter.SourceContext, | |||
} | |||
} | |||
|
|||
// Non md or image relative link, so needs link to be glued. | |||
if !isMDFile(relDest) && !isImgFile(relDest) && r.glueLink != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We could try to check for r.glueLink
first as it's the most "important" one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
03342cd
to
1be5367
Compare
glueLink
to transform configlinkPrefixForNonMarkdownResources
to transform config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks 💪🏽
This PR adds
linkPrefixForNonMarkdownResources
option to mdox transform config. This allowsmdox
to prefix non-markdown or image relative links with URL.So with config set to
linkPrefixForNonMarkdownResources: https://github.com/bwplotka/mdox/tree/main
, relative links likepkg/mdformatter/mdformatter.go
will be converted tohttps://github.com/bwplotka/mdox/tree/main/pkg/mdformatter/mdformatter.go
. Fixes #74.