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

Support for <tt> for code/typewriter text #5

Closed
ljrk0 opened this issue Jul 20, 2022 · 1 comment
Closed

Support for <tt> for code/typewriter text #5

ljrk0 opened this issue Jul 20, 2022 · 1 comment

Comments

@ljrk0
Copy link

ljrk0 commented Jul 20, 2022

As per JohannesKaufmann/html-to-markdown#49, some websites don't use semantic markup but specify <tt> directly.

Adding this rule for the markdown converter improves the output considerably:

	converter.AddRules(
		md.Rule {
			Filter: []string{"tt"},
			Replacement: func(content string, selec *goquery.Selection, opt *md.Options) *string {
				content = "`" + content + "`"

				return &content
			},
		},
	);
@ljrk0
Copy link
Author

ljrk0 commented Jul 20, 2022

Note that this will not deal with collapsing of inline spaces, unescaping, etc. -- the logic already exists here https://github.com/JohannesKaufmann/html-to-markdown/blob/master/commonmark.go#L297 but uses private methods that'd need to be duplicated.

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

No branches or pull requests

2 participants