Horizontal rule
Add a divider between sections of a document.
horizontal_rule() adds a divider as a standalone block. Use it to separate two sections without adding a heading.
Try it
Section titled “Try it”Install
Section titled “Install”cargo add gpdoc-plugin-horizontal-ruleIn a GPUI editor, the default view draws the divider.
Example
Section titled “Example”Register a paragraph alongside the divider so the caret has a place to continue typing. Use this configuration in the Quickstart editor.
use gpdoc::EditorConfig;use gpdoc_plugin_paragraph::paragraph;use gpdoc_plugin_horizontal_rule::horizontal_rule;
let config = EditorConfig::builder() .plugin(paragraph()) .plugin(horizontal_rule()) .build() .expect("configure editor");At the start of a paragraph, type ---. The editor inserts the divider and puts the caret in a paragraph.
Insert a divider before a paragraph
Section titled “Insert a divider before a paragraph”use gpdoc::{Editor, Node};
let next_section = Node::textblock("paragraph", "Next section");let mut editor = Editor::from_document(&config, vec![next_section.clone()])?;editor.run(gpdoc_plugin_horizontal_rule::Set)?;
let blocks = editor.document().blocks();assert_eq!(blocks[0].kind, "horizontalRule");assert_eq!(blocks[1], next_section);Commands
Section titled “Commands”setHorizontalRule
Section titled “setHorizontalRule”Insert a divider where the schema permits one. At the start of a nonempty paragraph, it goes before the paragraph. In the middle, it splits the paragraph. A text range replaces the selected content, a gap selection inserts at the gap, and a node selection inserts after the node.
editor.run(gpdoc_plugin_horizontal_rule::Set)?;When the next sibling is a text block, the caret moves to its start. At the end of the document, the command creates a default text block after the divider if the parent permits it.
Insert a divider while typing
Section titled “Insert a divider while typing”Start a text block with ---. The third hyphen triggers the rule and consumes the marker. You can also type ___ or *** followed by a space. Inside code blocks, these markers remain literal punctuation.