csl-clio/Filtres-Pandoc/remove-superfluous-spaces.sh

27 lines
1.6 KiB
Bash
Raw Normal View History

2021-04-15 22:02:49 +01:00
########################################################################
# Copyright 2021 by Bastien Dumont (bastien.dumont@posteo.net)
#
# This file is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This file is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this file. If not, see <https://www.gnu.org/licenses/>.
#
########################################################################
#!/bin/bash
sed 's/ "},{"t":"Space"},/ "},/g' - | # Espace simple ajoutée entre le prénom et le nom.
sed 's/,{"t":"Space"},{"t":"Str","c":" /,{"t":"Str","c":" /g' | #
sed 's/. ,"}/.,"}/g' | # Espace insécable ajoutée après le prénom quand celui-ci vient après le nom (du fait du style CSL).
sed 's/\. "},{"t":"Str","c":","}/."},{"t":"Str","c":","}/g' | # Même chose dans une citation inline.
sed 's/\. -\([[:upper:]]\)/.-\1/g' | # Espace avant le tiret de séparation dans un prénom composé.
sed 's/,{"t":"Str","c":"("},{"t":"Space"}/,{"t":"Str","c":"("}/g' # Espace avant la citation quand elle suit immédiatement une parenthèse ouvrante