项目符号列表和有序列表也是 Markdown 中的容器块。它们的嵌套在 DOM 中的表示方式与使用样式继承的所有其他容器块相同。然而,此外,DOM 中的列表在列表样式或段落格式中具有相应的数字格式。
内联块
我们在翻译 Bold、Italic 或 删除线 内联 markdown 功能时使用 Font 格式。
Markdown 功能
Aspose.Words
Bold {1}
Font.bold = True
# Use a document builder to add content to the document.builder=aw.DocumentBuilder()# Make the text Bold.builder.font.bold=Truebuilder.writeln("This text will be Bold")builder.document.save(docs_base.artifacts_dir+"WorkingWithMarkdown.bold_text_example.md")
Italic *italic text*
Font.italic = True
# Use a document builder to add content to the document.builder=aw.DocumentBuilder()# Make the text Italic.builder.font.italic=Truebuilder.writeln("This text will be Italic")builder.document.save(docs_base.artifacts_dir+"WorkingWithMarkdown.italic_text_example.md")
Strikethrough ~Strikethrough text~
Font.strike_through = True
# Use a document builder to add content to the document.builder=aw.DocumentBuilder()# Make the text Strikethrough.builder.font.strike_through=Truebuilder.writeln("This text will be Strikethrough")builder.document.save(docs_base.artifacts_dir+"WorkingWithMarkdown.strikethrough_text_example.md")
# Use a document builder to add content to the document.builder=aw.DocumentBuilder()# Number of backticks is missed, one backtick will be used by default.inlineCode1BackTicks=builder.document.styles.add(aw.StyleType.CHARACTER,"InlineCode")builder.font.style=inlineCode1BackTicksbuilder.writeln("Text with InlineCode style with 1 backtick")# There will be 3 backticks.inlineCode3BackTicks=builder.document.styles.add(aw.StyleType.CHARACTER,"InlineCode.3")builder.font.style=inlineCode3BackTicksbuilder.writeln("Text with InlineCode style with 3 backtick")builder.document.save(docs_base.artifacts_dir+"WorkingWithMarkdown.inline_code_example.md")
# Use a document builder to add content to the document.builder=aw.DocumentBuilder()# Insert hyperlink.builder.insert_hyperlink("https://www.aspose.com","https://www.aspose.com",False);builder.insert_hyperlink("email@aspose.com","mailto:email@aspose.com",False);builder.document.save(docs_base.artifacts_dir+"WorkingWithMarkdown.autolink_example.md")
# Use a document builder to add content to the document.builder=aw.DocumentBuilder()# Insert hyperlink.builder.insert_hyperlink("Aspose","https://www.aspose.com",False)builder.document.save(docs_base.artifacts_dir+"WorkingWithMarkdown.link_example.md")
# Use a document builder to add content to the document.builder=aw.DocumentBuilder()# Insert image.shape=aw.drawing.Shape(builder.document,aw.drawing.ShapeType.IMAGE)shape.wrap_type=aw.drawing.WrapType.INLINEshape.image_data.source_full_name="/attachment/1456/pic001.png"shape.image_data.title="title"builder.insert_node(shape)builder.document.save(docs_base.artifacts_dir+"WorkingWithMarkdown.image_example.md")
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use a document builder to add content to the document.doc=aw.Document()builder=aw.DocumentBuilder(doc)builder.paragraph_format.style_name="Heading 1"builder.writeln("This is an H1 tag")# Reset styles from the previous paragraph to not combine styles between paragraphs.builder.font.bold=Falsebuilder.font.italic=FalsesetexHeading1=doc.styles.add(aw.StyleType.PARAGRAPH,"SetexHeading1")builder.paragraph_format.style=setexHeading1doc.styles.get_by_name("SetexHeading1").base_style_name="Heading 1"builder.writeln("Setex Heading level 1")builder.paragraph_format.style=doc.styles.get_by_name("Heading 3")builder.writeln("This is an H3 tag")# Reset styles from the previous paragraph to not combine styles between paragraphs.builder.font.bold=Falsebuilder.font.italic=FalsesetexHeading2=doc.styles.add(aw.StyleType.PARAGRAPH,"SetexHeading2")builder.paragraph_format.style=setexHeading2doc.styles.get_by_name("SetexHeading2").base_style_name="Heading 3"# Setex heading level will be reset to 2 if the base paragraph has a Heading level greater than 2.builder.writeln("Setex Heading level 2")builder.document.save(docs_base.artifacts_dir+"WorkingWithMarkdown.setext_heading_example.md")
# Use a document builder to add content to the document.builder=aw.DocumentBuilder()indentedCode=builder.document.styles.add(aw.StyleType.PARAGRAPH,"IndentedCode")builder.paragraph_format.style=indentedCodebuilder.writeln("This is an indented code")builder.document.save(docs_base.artifacts_dir+"WorkingWithMarkdown.indented_code_example.md")
# Use a document builder to add content to the document.builder=aw.DocumentBuilder()fencedCode=builder.document.styles.add(aw.StyleType.PARAGRAPH,"FencedCode")builder.paragraph_format.style=fencedCodebuilder.writeln("This is an fenced code")fencedCodeWithInfo=builder.document.styles.add(aw.StyleType.PARAGRAPH,"FencedCode.C#")builder.paragraph_format.style=fencedCodeWithInfobuilder.writeln("This is a fenced code with info string")builder.document.save(docs_base.artifacts_dir+"WorkingWithMarkdown.fenced_code_example.md")
# Use a document builder to add content to the document.doc=aw.Document()builder=aw.DocumentBuilder(doc)# By default a document stores blockquote style for the first level.builder.paragraph_format.style_name="Quote"builder.writeln("Blockquote")# Create styles for nested levels through style inheritance.quoteLevel2=doc.styles.add(aw.StyleType.PARAGRAPH,"Quote1")builder.paragraph_format.style=quoteLevel2doc.styles.get_by_name("Quote1").base_style_name="Quote"builder.writeln("1. Nested blockquote")builder.document.save(docs_base.artifacts_dir+"WorkingWithMarkdown.quote_example.md")
# Use a document builder to add content to the document.builder=aw.DocumentBuilder()builder.list_format.apply_bullet_default()builder.list_format.list.list_levels[0].number_format="-"builder.writeln("Item 1")builder.writeln("Item 2")builder.list_format.list_indent()builder.writeln("Item 2a")builder.writeln("Item 2b")builder.document.save(docs_base.artifacts_dir+"WorkingWithMarkdown.bulleted_list_example.md")
# Use a document builder to add content to the document.builder=aw.DocumentBuilder()# Add the first row.builder.insert_cell()builder.writeln("a")builder.insert_cell()builder.writeln("b")builder.end_row()# Add the second row.builder.insert_cell()builder.writeln("c")builder.insert_cell()builder.writeln("d")builder.end_table()builder.document.save(docs_base.artifacts_dir+"WorkingWithMarkdown.ordered_list_table.md")