Apple News组件中Markdown标题的样式

时间:2016-06-27 05:36:50

标签: markdown apple-news

我有以下生成的ANF文档:

{
  "version": "0.10.13",
  "identifier": "http://test.domain.com?p=123456",
  "title": "Test Apple News Post",
  "language": "en",
  "layout": {
    "columns": 7,
    "width": 1024
  },
  "components": [
    {
      "text": "Test Apple News Post",
      "role": "title",
      "layout": {
        "margin": {
          "bottom": 30
        }
      }
    },
    {
      "text": "# Heading 1\n\n## HEADING 2\n\n### Heading 3\n\n#### Heading 4\n\n##### Heading 5\n\n###### Heading 6",
      "format": "markdown",
      "role": "body",
      "layout": "bodyLayout"
    }
  ],
  "componentTextStyles": {
    "default": {
      "linkStyle": {
        "textColor": "#DF0033"
      },
      "fontName": "Georgia",
      "fontSize": 12
    },
    "default-title": {
      "fontName": "Georgia-Bold",
      "fontSize": 24
    },
    "default-heading": {
      "fontName": "Georgia-Bold",
      "fontSize": 24
    },
    "default-heading1": {
      "fontName": "Georgia-Bold",
      "fontSize": 24
    },
    "default-heading2": {
      "fontName": "DINCondensed-Bold",
      "fontSize": 18
    },
    "default-heading3": {
      "fontName": "Georgia-Bold",
      "fontSize": 22,
      "textColor": "#FF0000"
    },
    "default-heading4": {
      "fontName": "Georgia-Bold",
      "fontSize": 20,
      "textColor": "#00FF00"
    },
    "default-heading5": {
      "fontName": "Georgia-Bold",
      "fontSize": 18,
      "textColor": "#0000FF"
    },
    "default-heading6": {
      "fontName": "Georgia-Bold",
      "fontSize": 16,
      "textColor": "#FF00FF"
    }
  },
  "metadata": {
    "datePublished": "2016-06-06T04:25:34+00:00",
    "dateCreated": "2016-06-06T04:25:34+00:00",
    "dateModified": "2016-06-27T01:05:27+00:00",
    "canonicalURL": "http://test.domain.com?p=123456",
    "thumbnailURL": "http://dummyimage.com/1000x500/000/ffffff&text=Apple+News+Image+1",
    "keywords": [
      "tag1",
      "tag2",
      "tag3"
    ],
    "excerpt": "This is the excerpt text, woo!"
  },
  "componentLayouts": {
    "bodyLayout": {
      "columnStart": 0,
      "columnSpan": 7,
      "margin": {
        "bottom": 15
      }
    }
  }
}

我的问题是,就我所知,似乎字体大小从未应用于标题3到6。

我想要获得的目标是h1是Georgia Bold中的一个大标题(与文档中的title组件具有相同的样式),h3 - {{ 1}}是相同的逐渐变小的版本,h6是一个特殊情况,显示较小的,浓缩的标题样式。我希望这很简单,但这是我的输出:

Example Output

正如您所看到的,这里发生了一些奇怪的事情:

  1. 显然h2属性是从fontName中选取的,因为我们看到了那里使用的精简字体
  2. 我添加了default-heading2属性,以确保textColor - default-heading3执行任何操作都会被选中并应用。
  3. 我认为default-heading6属性至少在fontSize上被提取,但不能确定,也许这只是字体本身大小的差异。
  4. 我还尝试删除整个h2 default-heading,因为这可能是某种奇怪的继承事物,但没有看到任何变化。

    编辑:此外,我尝试完全颠倒根元素上componentTextStyle的顺序(以便首先定义componentTextStyle,然后定义default-heading6等,然后在default-heading5之后,最后定义了default-heading1,并且还根据预览应用生成的警告将根元素的default-heading属性增加到1.1.0。这些都没有改变输出。

1 个答案:

答案 0 :(得分:0)

好的,经过一些调查后,Apple News Format Documents中的标题似乎没有未记录的最小字体大小。我能通过试验和推测来推测这一点。在初始问题中对测试文档进行错误修改,最终导致以下内容:

{
  "version": "1.1.0",
  "identifier": "http://test.domain.com?p=123456",
  "title": "Test Apple News Post",
  "language": "en",
  "layout": {
    "columns": 7,
    "width": 1024
  },
  "components": [
    {
      "text": "Test Apple News Post",
      "role": "title",
      "layout": {
        "margin": {
          "bottom": 30
        }
      }
    },
    {
      "text": "# Heading 1\n\n## Heading 2\n\n### Heading 3\n\n#### Heading 4\n\n##### Heading 5\n\n###### Heading 6",
      "format": "markdown",
      "role": "body",
      "layout": "bodyLayout"
    }
  ],
  "componentTextStyles": {
    "default": {
      "linkStyle": {
        "textColor": "#DF0033"
      },
      "fontName": "Georgia",
      "fontSize": 12
    },
    "default-title": {
      "fontName": "Georgia-Bold",
      "fontSize": 24
    },
    "default-heading": {
      "fontName": "Georgia-Bold",
      "fontSize": 24
    },
    "default-heading1": {
      "fontName": "Georgia-Bold",
      "fontSize": 20
    },
    "default-heading2": {
      "fontName": "Georgia-Bold",
      "fontSize": 21
    },
    "default-heading3": {
      "fontName": "Georgia-Bold",
      "fontSize": 22,
      "textColor": "#FF0000"
    },
    "default-heading4": {
      "fontName": "Georgia-Bold",
      "fontSize": 23,
      "textColor": "#00FF00"
    },
    "default-heading5": {
      "fontName": "Georgia-Bold",
      "fontSize": 24,
      "textColor": "#0000FF"
    },
    "default-heading6": {
      "fontName": "Georgia-Bold",
      "fontSize": 25,
      "textColor": "#FF00FF"
    }
  },
  "metadata": {
    "datePublished": "2016-06-06T04:25:34+00:00",
    "dateCreated": "2016-06-06T04:25:34+00:00",
    "dateModified": "2016-06-27T01:05:27+00:00",
    "canonicalURL": "http://test.domain.com?p=123456",
    "thumbnailURL": "http://dummyimage.com/1000x500/000/ffffff&text=Apple+News+Image+1",
    "keywords": [
      "tag1",
      "tag2",
      "tag3"
    ],
    "excerpt": "This is the excerpt text, woo!"
  },
  "componentLayouts": {
    "bodyLayout": {
      "columnStart": 0,
      "columnSpan": 7,
      "margin": {
        "bottom": 15
      }
    }
  }
}

具有以下输出:

Heading Font Limit

由于字体仅从h6元素开始实际增加,我猜测标题字体大小被限制在最少24个点。