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 Support for <mark> #352

Closed
vkbo opened this issue Jun 27, 2020 · 6 comments
Closed

Add Support for <mark> #352

vkbo opened this issue Jun 27, 2020 · 6 comments
Assignees
Labels
potential feature Request: May be considered later wontfix Invalid: This will not be worked on

Comments

@vkbo
Copy link
Owner

vkbo commented Jun 27, 2020

It may be useful to add support for the HTML <mark> tag. It isn't part of Makrdown, but for instance editors like Zim supports it.

Personally, I find it mostly useful in note files as a way of highlighting text. As for markdown tags for it, ==text== is one option. For it to work, syntax highlighting themes need a highlight syntax class for background and text. Fallback can be to invert the regular colours.

@vkbo vkbo self-assigned this Jun 27, 2020
@vkbo vkbo added the potential feature Request: May be considered later label Jun 27, 2020
@johnblommers
Copy link

I find the <mark> tag very useful in my writing.

This opens up the possibility of allowing HTML tags in the text. Indeed that is one of Markdown's nifty features, passing HTML tags directly to the output.

@vkbo
Copy link
Owner Author

vkbo commented Jun 27, 2020

This opens up the possibility of allowing HTML tags in the text. Indeed that is one of Markdown's nifty features, passing HTML tags directly to the output.

I'm definitely not planning on making novelWriter a full markdown editor. There are plenty of excellent ones out there already, including the very editor I use for writing novelWriter itself.

The <mark> tag is trivial to implement if I go for a wrapping symbol set like ==, or anything that can just recycle the existing code for other formatting tags. I use this formatting a lot in Zim for instance, but the use case in a novel is limited, unless you need a tag that can be replaced with underscore in the final result.

The features I'm considering adding are mark and quotes. They are both trivial to add as they can reuse existing parsing logic and easily be implemented into the tokenizer for the HTML converter.

@johnblommers
Copy link

I'm definitely not planning on making novelWriter a full markdown editor.

There is a huge amount of scope creep involved in making novelWriter a full markdown editor. novelWriter's meant for writing novels. It's not clear to me how you convert novelWriter Markdown into HTML because I've not looked at the underlying codebase. My guess is you're not using any existing Markdown converter. This is good because it reduces the amount of dependencies. Choosing not to use Pandoc to produce LaTeX and PDF was a good move for the same reason.

If I want to do something fancier with a novel, I have the option of exporting it out of novelWriter and hacking on the Markdown with another tool.

This is my long winded way of saying I agree with your approach.

@vkbo
Copy link
Owner Author

vkbo commented Jun 28, 2020

There is a huge amount of scope creep involved in making novelWriter a full markdown editor. novelWriter's meant for writing novels.

Precisely. I am happy to add features that are clearly useful for providing the core text of a novel, but I want to keep the scope narrow. I'm using Python, which gives me more flexibility of run environments, but limits how much I can modify the core widget classes of Qt to add features they don't already have. While it is usually technically possible, it will quickly slow down the application. At the moment, novelWriter is relatively responsive and fast (with a few exceptions when working with very large files).

I don't intend novelWriter to be used for writing non-fiction. Especially technical or academic work that requires a lot of research and the ability to add references etc. That is best done in a full featured text editor, or more sensibly (in my opinion) in LaTeX. I've written a couple of theses in my time ...

It's not clear to me how you convert novelWriter Markdown into HTML because I've not looked at the underlying codebase. My guess is you're not using any existing Markdown converter.

The tokenizer is custom written to handle a number of novelWriter-specific settings like page layouts and header formatting, tag parsing etc. So using a standard converter isn't an option. Also, the tokenizer class itself only produces a Python list with one entry per line in the source file. It will note what type of line it is, its original line number, the cleaned up text, the formatting to be applied at specific locations in the text, and the overall style of the line (alignment flags mostly). You have to subclass it to produce and implement a convert function to do the final conversion from the token list to another format.

It was written this way since I had subclasses for HTML, plain text, LaTeX, markdown, etc in the original implementation. I'm still considering adding my own ODF subclass.

The core tokenizer function isn't big, but probably a bit hard to follow: https://github.com/vkbo/novelWriter/blob/master/nw/core/tokenizer.py#L287

In addition, a second pass is run on the token array to apply layout-specific header formatting and auto-replaces. the final conversion is done as a third pass in a subclass dedicated to the format. For HTML it's nw/core/tohtml.py.

@vkbo
Copy link
Owner Author

vkbo commented Jan 29, 2021

Added a feature #595 for the part about block quotes mentioned here. I've started on a branch, but I wasn't very happy with the result, so I will probably try a different approach when I'm done messing with the export code.

I've added proper ODT export in the dev branch now, and will add a new parser to produce standard markdown as well. This should all be available in Version 1.2.

@vkbo vkbo added this to the Release 1.4 Beta 1 milestone Mar 14, 2021
@vkbo
Copy link
Owner Author

vkbo commented Apr 23, 2021

After some code tinkering and testing, I've decided to not implement this feature. I have a different proposal that may be better in #705.

@vkbo vkbo closed this as completed Apr 23, 2021
@vkbo vkbo removed this from the Release 1.4 Beta 1 milestone Apr 23, 2021
@vkbo vkbo added the wontfix Invalid: This will not be worked on label Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential feature Request: May be considered later wontfix Invalid: This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants