CodeMagic is an advanced source code editor plugin for Tinymce. It integrates the CodeMirror library for syntax coloring, and the JSBeautifier library for code formating and indentation.
MIT License
33
stars
14
forks
source link
HTML Inline Elements support - whitespace sensitive formatting for inline tags #9
HTML inline elements are sensitive to whitespace. Previous version of code applied new line to all tags which introduced unwnated whitespace in rendered HTML. I added and modified logic in beautify-html.js to handle these cases.
Change notes include:
added: (array) Parser.Utils.inline_token - to hold list of HTML inline elements for identification
added: (string) TK_TAG_INLINE token` - to handle formatting of inline tags specifically
added: (bool) Parser.found_leading_whitespace - to help with conditional inline tag formatting
added: (bool) Parser.found_trailing_whitespace - to help with conditional inline tag formatting
added: Comments through out the file to help follow flow of data and understand algorithm
fixed: Space left when trimming whitespace after "<" inside tag (e.g. < tag>). Now outputs <tag>
changed: get_token(), get_string(), get_content(), and get_tag() only return array[string, string] (previously array[string, string] or just string)
changed: unfinished content (unclosed tags or scripts) now get formatted even when EOF is reached
todo: add option to print inline tags on same line as content (inline tags currently get newline if whitespace allows)
HTML inline elements are sensitive to whitespace. Previous version of code applied new line to all tags which introduced unwnated whitespace in rendered HTML. I added and modified logic in beautify-html.js to handle these cases.
Change notes include:
(array) Parser.Utils.inline_token
- to hold list of HTML inline elements for identification(string) TK_TAG_INLINE
token` - to handle formatting of inline tags specifically(bool) Parser.found_leading_whitespace
- to help with conditional inline tag formatting(bool) Parser.found_trailing_whitespace
- to help with conditional inline tag formatting< tag>
). Now outputs<tag>
get_token()
,get_string()
,get_content()
, andget_tag()
only returnarray[string, string]
(previouslyarray[string, string]
or juststring
)<em>italic <strong>and bold</strong><em>
)