中断 ====== Breaks .. tab:: 中文 Word 支持多种中断文档中文本流动的分隔符: * 换行符 * 分页符 * 列分隔符 * 节分隔符(新页面、偶数页、奇数页) 此外,可以通过将段落设置为“分页前”来强制分页。 本分析仅限于换行符、分页符和列分隔符。节分隔符使用完全不同的一组元素实现,单独进行说明。 .. tab:: 英文 Word supports a variety of breaks that interrupt the flow of text in the document: * line break * page break * column break * section break (new page, even page, odd page) In addition, a page break can be forced by formatting a paragraph with the "page break before" setting. This analysis is limited to line, page, and column breaks. A section break is implemented using a completely different set of elements and is covered separately. 候选协议 -- run.add_break() ------------------------------------- Candidate protocol -- run.add_break() .. tab:: 中文 以下交互式会话演示了添加分页符的协议 .. tab:: 英文 The following interactive session demonstrates the protocol for adding a page break :: >>> run = p.add_run() >>> run.breaks [] >>> run.add_break() # by default adds WD_BREAK.LINE >>> run.breaks [] >>> run.breaks[0].type.__name__ WD_BREAK.LINE >>> run.add_break(WD_BREAK.LINE) >>> run.breaks [, ] >>> run.add_break(WD_BREAK.PAGE) >>> run.add_break(WD_BREAK.COLUMN) >>> run.add_break(WD_BREAK.LINE_CLEAR_LEFT) >>> run.add_break(WD_BREAK.LINE_CLEAR_RIGHT) >>> run.add_break(WD_BREAK.TEXT_WRAPPING) 枚举 -- WD_BREAK_TYPE ---------------------------- Enumeration -- WD_BREAK_TYPE * WD_BREAK.LINE * WD_BREAK.LINE_CLEAR_LEFT * WD_BREAK.LINE_CLEAR_RIGHT * WD_BREAK.TEXT_WRAPPING (e.g. LINE_CLEAR_ALL) * WD_BREAK.PAGE * WD_BREAK.COLUMN * WD_BREAK.SECTION_NEXT_PAGE * WD_BREAK.SECTION_CONTINUOUS * WD_BREAK.SECTION_EVEN_PAGE * WD_BREAK.SECTION_ODD_PAGE 样本 XML ------------ Specimen XML .. highlight:: xml 换行符 ~~~~~~~~~~ Line break .. tab:: 中文 以下 XML 是 Word 在使用 Shift-Enter 插入换行符后生成的:: Text before and after line break Word 可以正常加载这种更直接的生成方式,尽管它在下次保存时会将其更改。我不确定创建一个新的 run,使得 ```` 元素成为第一个子元素的优势何在:: Text before and after line break .. tab:: 英文 This XML is produced by Word after inserting a line feed with Shift-Enter:: Text before and after line break Word loads this more straightforward generation just fine, although it changes it back on next save. I'm not sure of the advantage in creating a fresh run such that the ```` element is the first child:: Text before and after line break 分页符 ~~~~~~~~~~ Page break .. tab:: 中文 从这个 XML 开始... :: Before inserting a page break, the cursor was here } This was the following paragraph, the last in the document ... 这是 Word 在插入硬分页时生成的 XML:: Before inserting a page break, the cursor was here } This was the following paragraph, the last in the document Word 可以正常加载以下简化形式... :: Text before an intra-run page break Text after an intra-run page break following paragraph ... 然而在保存时,它会将其转换为以下形式:: Text before an intra-run page break Text after an intra-run page break following paragraph .. tab:: 英文 Starting with this XML ... :: Before inserting a page break, the cursor was here } This was the following paragraph, the last in the document ... this XML is produced by Word on inserting a hard page:: Before inserting a page break, the cursor was here } This was the following paragraph, the last in the document Word loads the following simplified form fine ... :: Text before an intra-run page break Text after an intra-run page break following paragraph ... although on saving it converts it to this:: Text before an intra-run page break Text after an intra-run page break following paragraph 架构摘录 -------------- Schema excerpt .. highlight:: xml :: 资源 --------- Resources * `WdBreakType Enumeration on MSDN`_ * `Range.InsertBreak Method (Word) on MSDN`_ .. _WdBreakType Enumeration on MSDN: http://msdn.microsoft.com/en-us/library/office/ff195905.aspx .. _Range.InsertBreak Method (Word) on MSDN: http://msdn.microsoft.com/en-us/library/office/ff835132.aspx ISO 规范中的相关部分 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Relevant sections in the ISO Spec * 17.18.3 ST_BrClear (Line Break Text Wrapping Restart Location)