news-catalyst / google-app-scripts

a collection of scripts for tinynews google docs add-ons
https://script.google.com/a/newscatalyst.org/d/1ILURq69o3cYUy6k1n1X6HwxdMfl9xWNhILYuZxgLfeblb3IR15WCMZSj/edit
1 stars 1 forks source link

Parse horizontal lines as <hr> #333

Closed TylerFisher closed 2 years ago

TylerFisher commented 2 years ago

In Google Docs you can insert a horizontal line by going to Insert > Horizontal Line. This should translate to an <hr>. (That appears to be the intention, pasting an <hr> from WordPress becomes the same horizontal line in Google Docs).

jacqui commented 2 years ago

A horizontal looks like this in the google docs markup JSON:

{
  "endIndex": 126,
  "startIndex": 124,
  "paragraph": {
    "paragraphStyle": {
      "direction": "LEFT_TO_RIGHT",
      "spaceAbove": {
        "magnitude": 12,
        "unit": "PT"
      },
      "spaceBelow": {
        "unit": "PT",
        "magnitude": 12
      },
      "namedStyleType": "NORMAL_TEXT"
    },
    "elements": [
      {
        "horizontalRule": {
          "textStyle": {}
        },
        "endIndex": 125,
        "startIndex": 124
      },
      {
        "startIndex": 125,
        "textRun": {
          "textStyle": {},
          "content": "\n"
        },
        "endIndex": 126
      }
    ]
  }
}

We could easily add another element type like so:

{
  "children": [],
  "link": null,
  "type": "hr",
  "index": 126
}