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

Finding issues and solution related to HTML-wrapping function #518

Open
keshav234156 opened this issue May 29, 2020 · 6 comments
Open

Finding issues and solution related to HTML-wrapping function #518

keshav234156 opened this issue May 29, 2020 · 6 comments

Comments

@keshav234156
Copy link
Member

keshav234156 commented May 29, 2020

HTML mode in woofmark uses wrapping function which is defined here https://github.com/bevacqua/woofmark/blob/master/src/html/wrapping.js . This function has various issues. It's used by Bold, Italic, Code and blockquote

  1. https://github.com/bevacqua/woofmark/blob/master/src/html/wrapping.js#L5 . variable close defined here works well for modules having one tag eg <strong> but doesn't work for modules like code which have more than one tag Eg code Module <pre><code> as closing tag should be </code></pre> and not </pre></code>. A possible solution could be to write a separate wrapping function for the code module.

  2. https://github.com/bevacqua/woofmark/blob/master/src/html/wrapping.js#L14 the leading variable defined here and rleading variable defined here https://github.com/bevacqua/woofmark/blob/master/src/html/wrapping.js#L6.

var rleading = new RegExp(open + '( [^>]*)?>$', 'i');

Now, this has $ in regex, which matches only the last of the string. But when the chunk is not selected it causes some abrupt behavior.
Eg in Code

  1. Press Ctrl + E to initiate (then remove the chunks.selection)
  2. Press Ctrl + E again. Now expected behavior should be to exit out of code module but the result is
    Screenshot from 2020-05-29 14-44-18

Bold module also behaves in a similar way;

What should be the possible solution for this?

  1. What should we possibly do to exit out of any module in HTML mode
    Eg like in markdown mode, for Bold in markdown we do it through https://github.com/bevacqua/woofmark/blob/master/src/markdown/boldOrItalic.js#L23-L26

@Shreyaa-s Any more bugs related to this to wrapping function?

@keshav234156
Copy link
Member Author

@keshav234156
Copy link
Member Author

Hi @bevacqua !! .If you could also suggest the possible solution to above problems that will be highly thankful!!

@VladimirMikulic
Copy link
Contributor

Since Woofmark is no longer maintained, our best bet is to fork it and patch issues.

@keshav234156
Copy link
Member Author

@VladimirMikulic that not the problem
we are already using a it from https://github.com/jywarren/woofmark . I mean to say what are changes/possible solution to above listed problem

@shreyaa-s-zz
Copy link
Collaborator

I think it might be worth mentioning that wrapping functions makes changes to the selected text like in #457 (comment) and #487 (comment) and these changes are not always desirable.

@Shulammite-Aso
Copy link
Collaborator

Shulammite-Aso commented May 29, 2020

Hi all.

Here at https://bevacqua.github.io/woofmark/ the HTML mode works fine for both bold formatting and exiting out of code block, the issues only occur in wysiwyg mode.

I think this should possibly be because some extra tags like the <br> tag and some characters like &nbsp get added to the markup when you type in wysiwyg mode making it messy, and the wrapping function is not checking for and filtering out these tags. It assumes the markup should be the normal and clean html.

To confirm this, try typing some formatted text in the HTML mode, and seeing the markup and then typing exactly the same thing again in WYSIWYG mode, switch to HTML and see the markup it produced. They don't come out the same.
Another option is to consle.log chunks in the boldOrItalic module to see the output of before and after selection after using bold or italics.

I think we need to identify when these tags are inserted and get the wrapping function to also filter out the extra tags and characters.

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

4 participants