| degender |
|---|
_ |
An alle Tester:innen, das ist wichtig: Testen!
| --- Replace intra-word colons with gender star or gap | |
| -- | |
| -- Copyright 2022 Frederik Elwert <[email protected]> | |
| -- | |
| -- LICENSE | |
| -- | |
| -- Permission is hereby granted, free of charge, to any person obtaining a copy | |
| -- of this software and associated documentation files (the "Software"), to | |
| -- deal in the Software without restriction, including without limitation the | |
| -- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |
| -- sell copies of the Software, and to permit persons to whom the Software is | |
| -- furnished to do so, subject to the following conditions: | |
| -- | |
| -- The above copyright notice and this permission notice shall be included in | |
| -- all copies or substantial portions of the Software. | |
| -- | |
| -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
| -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
| -- IN THE SOFTWARE. | |
| local DEFAULT_DEGENDER_MARKER = '*' | |
| local degender_marker | |
| function split_hyphen(inputstr) | |
| local sep = ':' | |
| local t = {} | |
| for str in string.gmatch(inputstr, '([^'..sep..']+)') do | |
| table.insert(t, str) | |
| end | |
| return t | |
| end | |
| function Meta(meta) | |
| if meta['degender'] then | |
| degender_marker = pandoc.utils.stringify(meta['degender']) | |
| else | |
| degender_marker = DEFAULT_DEGENDER_MARKER | |
| end | |
| end | |
| function Str(elem) | |
| local parts = split_hyphen(elem.text) | |
| -- if not more than one part, string contains no hyphen, return unchanged. | |
| if #parts <= 1 then | |
| return nil | |
| end | |
| -- otherwise, replace with degender marker | |
| local o = {} | |
| for index, part in ipairs(parts) do | |
| table.insert(o, pandoc.Str(part)) | |
| if index < #parts then | |
| table.insert(o, pandoc.Str(degender_marker)) | |
| end | |
| end | |
| return o | |
| end | |
| return {{Meta = Meta}, {Str = Str}} |
| degender |
|---|
_ |
An alle Tester:innen, das ist wichtig: Testen!