question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handling Complex Headings

See original GitHub issue

It appears that headings with any sort of complexity (i.e. part bold, part normal) are being split and not fully processed. An example would be a simple document such as this:

image

(Available at https://docs.google.com/document/d/1cZ7o50cWtnljBFhLabvvAHRTnSeu13Yr1jHFx0ol5CQ/edit?usp=sharing)

Expected Behavior

I would expect this to render as:

##  **Part Bold** Part Not\n\n\nSome other text\n

or in HTML as:

<h2><strong>Part Bold<strong> Part Not</h2>\n<p>Some other text</p>

Actual Behavior

The “Part Bold” item is omitted from the output. Renders as:

##  Part Not\n\n\nSome other text\n

and

<h2>Part Not</h2>\n<p>Some other text</p>

Info

Here is an example query in Gatsby:

{
  googleDocs(slug: {eq: "/debug"}) {
    childMarkdownRemark {
      rawMarkdownBody
      html
    }
    document {
      body {
        content {
          paragraph {
            paragraphStyle {
              namedStyleType
            }
            elements {
              textRun {
                content
              }
            }
          }
        }
      }
    }
  }
}

and the resulting output, which shows that the “Part Bold” item is in the Google Docs API response:

{
  "data": {
    "googleDocs": {
      "childMarkdownRemark": {
        "rawMarkdownBody": "##  Part Not\n\n\nSome other text\n",
        "html": "<h2>Part Not</h2>\n<p>Some other text</p>"
      },
      "document": {
        "body": {
          "content": [
            {
              "paragraph": null
            },
            {
              "paragraph": {
                "paragraphStyle": {
                  "namedStyleType": "HEADING_1"
                },
                "elements": [
                  {
                    "textRun": {
                      "content": "Part Bold"
                    }
                  },
                  {
                    "textRun": {
                      "content": " Part Not\n"
                    }
                  }
                ]
              }
            },
            {
              "paragraph": {
                "paragraphStyle": {
                  "namedStyleType": "NORMAL_TEXT"
                },
                "elements": [
                  {
                    "textRun": {
                      "content": "Some other text\n"
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    }
  },
  "extensions": {}
}

If you think the expected behavior is correct and can give some pointers as to where to start looking, I’d be happy to submit a pull request with a fix

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
cedricdelpouxcommented, Mar 11, 2021

Thank you for reporting this! There was a bug with all options. It’s now resolved with 2.0.1 version.

1reaction
cedricdelpouxcommented, Feb 24, 2021

It strange that demoteHeadings option change the behaviour because it should just change the title level.

For the “bold” case, there is a specific case. Unfortunately, Google Docs default headings are bold. So bold is disabled for headings here to avoid DOM to be <h2><b>Heading</b></h2> all the time. I think heading should be style using css h2 { font-weight: bold } for example.

But for your use case, “Part Bold” text should be there!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tables with Multi-Level Headers - W3C
This page covers tables that have multi-level header cells associated per data cell. Such tables are too complex to identify a strict horizontal...
Read more >
Complex headers (rowspan and colspan) - DataTables example
Name Position Salary Office Extn. E‑mail Airi Satou Accountant $162,700 Tokyo 5407 a.satou... Angelica Ramos Chief Executive Officer (CEO) $1,200,000 London 5797 a.ramos... Ashton Cox Junior...
Read more >
Managing Heading Levels In Design Systems | by Heydon
While individual patterns/components within a design system can — and should — use headings, it's difficult to know which heading levels ...
Read more >
Complex Table Header IDs - YouTube
Kenny Moore of TaggedPDF.com presents a suggestion for remediating a complex table for accessibility using Header IDs.
Read more >
How to handle complex header recursion with variants and ...
One possible solution is to split headers into forward declarations and implementations: // AB_forward.hpp #pragma once #include <ostream> ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found