You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Results in the following markdown on Safari and Chrome:
# Heading with bold and _emphasized_ text
Normal text
In Firefox, the bold is preserved, and you get this output:
# Heading with **bold** and _emphasized_ text
Normal text
I think what we’re gettin in Firefox is better, and we should make sure this happens in other browsers, too. (Even though Markdown is really a shortcut syntax for HTML and most HTML renderers will already make the heading bold, there is semantic meaning here worth preserving. And some Markdown renderers might handle this case specially and still differentiate the text from the rest of the heading somehow.)
As far as why this happens: Google Docs wraps the content of headings in <span style="font-weight: 400"> (for normal text) and in <span style="font-weight: 700"> (for explicitly bolded text) the same as anywhere else in a document. But some browsers (WebKit and Chrome, but not Firefox; I’m not sure about other more niche engines) normalize the styling of the bolded text by removing the font-weight property, since the weight can be inherited from the heading it’s in (since the browser’s default styling of the heading is to make it bold).
I can see two obvious approaches to solving this:
Identify headers where some text has font-weight: 400 or font-weight: normal and other text has no font-weight at all, and update the latter text to be bold.
When resolving styles in lib/css.js, include some default styles for some elements (in this case font-weight: bold for headings).
The second approach is probably simpler, but it might result in unnecessarily bolding text in headings that are pasted in from other web pages, e.g:
# **Heading Text**
While non-Google-Docs source HTML is not our primary concern here, it would be nice not to make it worse than the current situation.
Note: this was originally mixed in a bit subtly with the tests in #104; I’m extracting it into a separate issue here.
The text was updated successfully, but these errors were encountered:
Mr0grog
added a commit
to trustedtomato/google-docs-to-markdown
that referenced
this issue
Nov 29, 2023
This simplifies the `internal-links` test fixture a bit in order to keep it focused. This also removes some complicated markup around boldness in the headings because things get complicated there, and made a separate issue about it: Mr0grog#113.
I've also moved the fixture to our official GDocs fixture folder.
Fixes#113 by looking for headings with a mix of children with normal/400 weight and no set weight, then updating the children with no set weight to be bold.
If part of a heading is bold in a Google doc, the bold text does not get surrounded with
**
bold markdown sytnax — except in Firefox.For example, in this document: https://docs.google.com/document/d/1lU6N1g5jmyvxZebY1JZpdVtS5SOLlaf65i1b7FilRfY/
Results in the following markdown on Safari and Chrome:
# Heading with bold and _emphasized_ text Normal text
In Firefox, the bold is preserved, and you get this output:
# Heading with **bold** and _emphasized_ text Normal text
I think what we’re gettin in Firefox is better, and we should make sure this happens in other browsers, too. (Even though Markdown is really a shortcut syntax for HTML and most HTML renderers will already make the heading bold, there is semantic meaning here worth preserving. And some Markdown renderers might handle this case specially and still differentiate the text from the rest of the heading somehow.)
As far as why this happens: Google Docs wraps the content of headings in
<span style="font-weight: 400">
(for normal text) and in<span style="font-weight: 700">
(for explicitly bolded text) the same as anywhere else in a document. But some browsers (WebKit and Chrome, but not Firefox; I’m not sure about other more niche engines) normalize the styling of the bolded text by removing thefont-weight
property, since the weight can be inherited from the heading it’s in (since the browser’s default styling of the heading is to make it bold).I can see two obvious approaches to solving this:
font-weight: 400
orfont-weight: normal
and other text has nofont-weight
at all, and update the latter text to be bold.lib/css.js
, include some default styles for some elements (in this casefont-weight: bold
for headings).The second approach is probably simpler, but it might result in unnecessarily bolding text in headings that are pasted in from other web pages, e.g:
# **Heading Text**
While non-Google-Docs source HTML is not our primary concern here, it would be nice not to make it worse than the current situation.
Note: this was originally mixed in a bit subtly with the tests in #104; I’m extracting it into a separate issue here.
The text was updated successfully, but these errors were encountered: