github errata-ai/vale v2.15.0

latest releases: v3.4.2, v3.4.1, v3.4.0...
2 years ago

This release introduces a new extension point, script, that allows for the creation of rules that require programming logic. The extension point uses the embedded language Tengo and is supported on all platforms.

# An example rule for suggesting a new section after 3 paragraphs of text.
extends: script
message: "Consider inserting a new section heading at this point."
link: https://tengolang.com/
# The unprocessed file contents.
#
# We need this to access heading markup.
scope: raw
script: |
  text := import("text")
  matches := []
  p_limit := 3 // at most 3 paragraphs per section
  // Remove all instances of code blocks since we don't want to count
  // inter-block newlines as a new paragraph.
  document := text.re_replace("(?s) *(\n```.*?```\n)", scope, "")
  count := 0
  for line in text.split(document, "\n") {
    if text.has_prefix(line, "#") {
      count = 0 // New section; reset count
    } else if count > p_limit {
      start := text.index(scope, line)
      matches = append(matches, {begin: start, end: start + len(line)})
      count = 0
    } else if text.trim_space(line) == "" {
      count += 1
    }
  }

Also check out the new online Rule Explorer app.

Changelog

  • b5424ea fix: ensure order of sections is preserved (#403)
  • 5e23684 fix: use new titlecase library

Don't miss a new vale release

NewReleases is sending notifications on new releases.