pub struct BlocksConfig {
pub auto_unicode_quotes: bool,
pub ligature_unicode_quotes: bool,
pub ligature_unicode_dashes: bool,
pub ligature_unicode_ellipses: bool,
}Expand description
The options of text resolution in the block-structure pass: one flag per family of typographic substitutions. Collapsing whitespace always happens and has no flag.
Every family is on by default, so that FLM source written with the usual TeX
spellings (`quoted', --, ...) is shown as its author meant it in
every output format. Switch a family off to have those spellings reach the
output unchanged.
A value is passed to structure, or to the blocks
feature’s constructor
(Blocks::new). Because
every field is public, a value can be built from the default with one change,
or from no_typography with one family
switched on. In settings written as data (crate::core::settings), the
fields are the settings keys of the blocks feature, and a key left out
takes its default.
§Examples
use flm_core::lang::rewrites::blocks::BlocksConfig;
let default = BlocksConfig::new();
assert!(default.any_typography());
// Everything but the dash ligatures.
let config = BlocksConfig { ligature_unicode_dashes: false, ..default };
assert!(config.any_typography());
assert!(!BlocksConfig::no_typography().any_typography());Fields§
§auto_unicode_quotes: boolWhether the straight double quote " and the straight single quote '
become curly quotes, opening (“, ‘) or closing (”, ’) according
to their position. When
ligature_unicode_quotes is
also on, the two-character ligature '' is that family’s, and this test
applies to a single '.
A quote opens at the start of a text run that no content precedes (a
comment does not count, nor the spaces ~ and \ ), and after
whitespace, an opening bracket
((, [, {) or a dash (-, –, —). A single quote also opens
before a digit (x'9 becomes x‘9), except in a decade abbreviation:
after a letter, a digit or an underscore, and before two digits and an
s (x'90s becomes
x’90s). A quote closes everywhere else: don't becomes don’t. The
test looks at the node before the text run, so in \(A_j\)'s the quote
after the formula closes.
ligature_unicode_quotes: boolWhether the TeX quote ligatures apply: `` becomes “, ''
becomes ”, and ` becomes ‘. A single ' becomes ’, as in
TeX, only when auto_unicode_quotes is
off; when both families are on, the position test of
auto_unicode_quotes decides a single '.
ligature_unicode_dashes: boolWhether the TeX dash ligatures apply: --- becomes an em dash — and
-- an en dash –.
ligature_unicode_ellipses: boolWhether the ellipsis ligature applies: ... becomes ….
Implementations§
Source§impl BlocksConfig
impl BlocksConfig
Sourcepub fn new() -> BlocksConfig
pub fn new() -> BlocksConfig
The default options: every family of substitutions on. Returns the same
value as BlocksConfig::default.
Sourcepub fn no_typography() -> BlocksConfig
pub fn no_typography() -> BlocksConfig
The options with every family of substitutions off. Whitespace is still collapsed, which no option can switch off.
Sourcepub fn any_typography(&self) -> bool
pub fn any_typography(&self) -> bool
Whether at least one family of substitutions is on.
Trait Implementations§
Source§impl Clone for BlocksConfig
impl Clone for BlocksConfig
impl Copy for BlocksConfig
Source§impl Debug for BlocksConfig
impl Debug for BlocksConfig
Source§impl Default for BlocksConfig
impl Default for BlocksConfig
Source§fn default() -> BlocksConfig
fn default() -> BlocksConfig
Source§impl<'de> Deserialize<'de> for BlocksConfigwhere
BlocksConfig: Default,
impl<'de> Deserialize<'de> for BlocksConfigwhere
BlocksConfig: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for BlocksConfig
Source§impl Hash for BlocksConfig
impl Hash for BlocksConfig
Source§impl JsonSchema for BlocksConfig
impl JsonSchema for BlocksConfig
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for BlocksConfig
impl PartialEq for BlocksConfig
Source§impl Serialize for BlocksConfig
impl Serialize for BlocksConfig
impl StructuralPartialEq for BlocksConfig
Auto Trait Implementations§
impl Forget for BlocksConfig
impl Freeze for BlocksConfig
impl Move for BlocksConfig
impl RefUnwindSafe for BlocksConfig
impl Send for BlocksConfig
impl Sync for BlocksConfig
impl Unpin for BlocksConfig
impl UnsafeUnpin for BlocksConfig
impl UnwindSafe for BlocksConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more