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

Add linkPrefixForNonMarkdownResources to transform config #76

Merged
merged 2 commits into from
Aug 24, 2021

Conversation

saswatamcode
Copy link
Collaborator

@saswatamcode saswatamcode commented Aug 15, 2021

This PR adds linkPrefixForNonMarkdownResources option to mdox transform config. This allows mdox to prefix non-markdown or image relative links with URL.
So with config set tolinkPrefixForNonMarkdownResources: https://github.com/bwplotka/mdox/tree/main, relative links like pkg/mdformatter/mdformatter.go will be converted to https://github.com/bwplotka/mdox/tree/main/pkg/mdformatter/mdformatter.go. Fixes #74.

@saswatamcode saswatamcode self-assigned this Aug 15, 2021
Copy link
Owner

@bwplotka bwplotka left a 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 💪🏽

- "testdata/test.md"
- "testdata/teststatic"

glueLink: "https://github.com/bwplotka/mdox/tree/main"
Copy link
Owner

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@@ -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 != "" {
Copy link
Owner

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.

Copy link
Collaborator Author

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 Show resolved Hide resolved
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
@saswatamcode saswatamcode changed the title Add glueLink to transform config Add linkPrefixForNonMarkdownResources to transform config Aug 22, 2021
Copy link
Owner

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks 💪🏽

@bwplotka bwplotka merged commit db5c373 into bwplotka:main Aug 24, 2021
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.

Support for non-doc local git links
2 participants