Hard break
Insert a line break within a paragraph.
hard_break() adds an inline break. Use it for content such as an address that needs several lines within one paragraph.
Try it
Section titled “Try it”Install
Section titled “Install”cargo add gpdoc-plugin-hard-breakRegister hard_break() with paragraph(). The inline hardBreak node takes no attributes.
Example
Section titled “Example”Register the inline break alongside a paragraph that can contain it. Use this configuration in the Quickstart editor.
use gpdoc::EditorConfig;use gpdoc_plugin_paragraph::paragraph;use gpdoc_plugin_hard_break::hard_break;
let config = EditorConfig::builder() .plugin(paragraph()) .plugin(hard_break()) .build() .expect("configure editor");Type First, press Shift + Enter, and type Second. Both lines belong to the same paragraph.
Insert a break between two words
Section titled “Insert a break between two words”use gpdoc::{DocPos, Editor, Node, Selection};
let mut editor = Editor::from_document(&config, vec![Node::textblock("paragraph", "FirstSecond")])?;editor.select(Selection::caret(DocPos(6)))?;editor.run(gpdoc_plugin_hard_break::Set)?;
assert_eq!(editor.document().blocks().len(), 1);assert_eq!(editor.document().node_at(DocPos(6)).unwrap().kind, "hardBreak");The first paragraph’s text starts at position 1. Its five-character prefix First puts the break at position 6.
Commands
Section titled “Commands”setHardBreak
Section titled “setHardBreak”Insert an inline break at the caret or replace selected text with a break. The text selection must be in content that accepts an inline break. The next line keeps the active typing marks, so a bold word can continue in bold after the break.
editor.run(gpdoc_plugin_hard_break::Set)?;Keyboard shortcuts
Section titled “Keyboard shortcuts”| Shortcut | Action |
|---|---|
| Shift + Enter | Insert a hard break. |
| Mod + Enter | Insert a hard break. |