question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disallow leading space on prefix and trailing space on suffix

See original GitHub issue

In the MLZ extended schema, I’ve introduced a constraint to disallow leading space on (most) prefixes and trailing space on (most) suffixes, as described in this post to an earlier xbiblio-devel thread and this followup.

This renders most (if not all) styles in the official repo invalid under this schema version, but it will prevent the issues flagged by Andrea in the thread from arising in the MLZ styles. Adjusting the main repo styles to satisfy this constraint would require a large (maybe prohibitively large) amount of work, but as Andrea noted, the resulting styles would be cleaner.

Anyway, here’s the patch for reference:

commit bf62c155531bdad482a780f11be92abcf2948c4f
Author: Frank <biercenator@gmail.com>
Date:   Thu Sep 22 01:00:32 2011 +0000

    Treat unnecessary leading prefix and trailing suffix spaces as invalid.

diff --git a/csl.rnc b/csl.rnc
index 9020579..9514bac 100644
--- a/csl.rnc
+++ b/csl.rnc
@@ -255,6 +255,11 @@ div {

             (localized-terms? & localized-dates* & localized-options?)
         }
+
+    ## Strings for use in affixes
+    nospace-prefix = xsd:string { pattern = "([^ ].*)*" }
+    nospace-suffix = xsd:string { pattern = "(.*[^ ])*" }
+
     localized-terms = element cs:terms { (simple-term | compound-term)+ }
     term-attributes =
         (( attribute form { cs-term-forms }?,
@@ -307,7 +312,7 @@ div {
             font-formatting,
             delimiter,
             element cs:date-part {
-                affixes, text-case, font-formatting, (month | day | year)
+                date-affixes, text-case, font-formatting, (month | day | year)
             }+
         }

@@ -520,7 +525,7 @@ div {
     names =
         element cs:names {
             names-attributes,
-            ((name?, et-al?, institution?) & name-label*),
+            (name-label-before?, name?, et-al?, institution?, name-label-after?),
             substitute?
         }

@@ -554,8 +559,16 @@ div {
         }

     ## Similar to label as below, but inherits variable from <names> tag
-    name-label = element cs:label {
+    name-label-before = element cs:label {
                      attribute form { cs-term-forms }?,
+                     attribute prefix { nospace-prefix}?,
+                     attribute suffix { text }?,
+                     label-primitives
+                 }
+    name-label-after = element cs:label {
+                     attribute form { cs-term-forms }?,
+                     attribute prefix { text }?,
+                     attribute suffix { nospace-suffix }?,
                      label-primitives
                  }

@@ -636,7 +649,7 @@ div {
                 ## order, the relevant `date-part`-elements, and by applying formatting,
                 ## affixes on cs:date and cs:date-part.
                 element cs:date-part {
-                    affixes, text-case, font-formatting, (month | day | year)
+                    date-affixes, text-case, font-formatting, (month | day | year)
                 }+,
                 delimiter)),
             affixes,
@@ -740,11 +753,11 @@ div {
     label =
         element cs:label {
             label-primitives,
+            affixes,
             attribute variable { cs-numbers | "locator" | "page" },
             attribute form { "long" | "short" | "symbol" }?
         }
     label-primitives =
-        affixes,
         font-formatting,
         text-case,
         strip-periods,
@@ -1031,6 +1044,9 @@ div {
 ## Formatting attributes.
 div {
     affixes =
+        attribute prefix { nospace-prefix }?,
+        attribute suffix { nospace-suffix }?
+    date-affixes =
         attribute prefix { text }?,
         attribute suffix { text }?
     delimiter = attribute delimiter { text }?

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bwiernikcommented, Jun 30, 2020

@bdarcus I suggest we close this. Thoughts?

0reactions
denismaiercommented, Jun 25, 2020

I also think we should keep this. While using groups is indeed best practice, there are a lot of cases where a simple affix is way easier.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Removing Leading and Trailing Spaces in Excel & Google Docs
Learn a few simple techniques to ensure that all your text data in Excel or Google Docs is clean and tidy by eliminating...
Read more >
Remove Spaces in Excel - Leading, Trailing and Double
In this tutorial, you will learn how to remove spaces in Excel. Trim function can remove leading and trailing spaces in text, double...
Read more >
How to remove spaces in Excel - leading, trailing, non-breaking
You will learn how to delete leading and trailing spaces in a cell, eliminate extra spaces between words, get rid of non-breaking white...
Read more >
Remove leading and trailing spaces from text - Excel formula
The TRIM function is fully automatic. It removes removes both leading and trailing spaces from text, and also "normalizes" multiple spaces between words...
Read more >
How to remove leading and/or trailing spaces of a string in T ...
The example below removes the space at the end of each company by using RTRIM() function. FROM company; The query returns the name...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found