Skip to content

Commit

Permalink
Remove attempt to convert all caps headings to sentence case (#1082)
Browse files Browse the repository at this point in the history
  • Loading branch information
nlisgo authored Sep 20, 2024
1 parent b511a5f commit b58e98c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 41 deletions.
18 changes: 9 additions & 9 deletions src/codecs/jats/__file_snapshots__/87253.json
Original file line number Diff line number Diff line change
Expand Up @@ -7187,7 +7187,7 @@
"id": "s1",
"depth": 1,
"content": [
"Introduction"
"INTRODUCTION"
]
},
{
Expand Down Expand Up @@ -7703,7 +7703,7 @@
"id": "s2",
"depth": 1,
"content": [
"Results"
"RESULTS"
]
},
{
Expand Down Expand Up @@ -9904,7 +9904,7 @@
"id": "s3",
"depth": 1,
"content": [
"Discussion"
"DISCUSSION"
]
},
{
Expand Down Expand Up @@ -10257,7 +10257,7 @@
"id": "s4",
"depth": 1,
"content": [
"Materials and methods"
"MATERIALS AND METHODS"
]
},
{
Expand Down Expand Up @@ -10763,7 +10763,7 @@
"id": "s4j",
"depth": 2,
"content": [
"3 race"
"3’RACE"
]
},
{
Expand Down Expand Up @@ -10901,7 +10901,7 @@
"id": "s5",
"depth": 1,
"content": [
"Data availability"
"DATA AVAILABILITY"
]
},
{
Expand All @@ -10918,7 +10918,7 @@
"id": "s6",
"depth": 1,
"content": [
"Funding"
"FUNDING"
]
},
{
Expand Down Expand Up @@ -10951,7 +10951,7 @@
"id": "s7",
"depth": 1,
"content": [
"Conflict of interest"
"CONFLICT OF INTEREST"
]
},
{
Expand All @@ -10968,7 +10968,7 @@
"id": "s8",
"depth": 1,
"content": [
"Author contributions"
"AUTHOR CONTRIBUTIONS"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6753,7 +6753,7 @@
"id": "s1",
"depth": 1,
"content": [
"Introduction"
"INTRODUCTION"
]
},
{
Expand Down Expand Up @@ -7008,7 +7008,7 @@
"id": "s2",
"depth": 1,
"content": [
"Results"
"RESULTS"
]
},
{
Expand Down Expand Up @@ -8937,7 +8937,7 @@
"id": "s3",
"depth": 1,
"content": [
"Discussion"
"DISCUSSION"
]
},
{
Expand Down Expand Up @@ -9388,7 +9388,7 @@
"id": "s4",
"depth": 1,
"content": [
"Materials and methods"
"MATERIALS AND METHODS"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"type": "Heading",
"depth": 1,
"content": [
"Summary"
"SUMMARY"
]
},
{
Expand Down Expand Up @@ -4312,7 +4312,7 @@
"id": "s1",
"depth": 1,
"content": [
"Introduction"
"INTRODUCTION"
]
},
{
Expand Down Expand Up @@ -4851,7 +4851,7 @@
"id": "s2",
"depth": 1,
"content": [
"Results"
"RESULTS"
]
},
{
Expand Down Expand Up @@ -6205,7 +6205,7 @@
"id": "s3",
"depth": 1,
"content": [
"Discussion"
"DISCUSSION"
]
},
{
Expand Down Expand Up @@ -6389,7 +6389,7 @@
"id": "s4",
"depth": 1,
"content": [
"Materials and methods"
"MATERIALS AND METHODS"
]
},
{
Expand Down Expand Up @@ -6712,7 +6712,7 @@
"id": "s5",
"depth": 1,
"content": [
"Data availability"
"DATA AVAILABILITY"
]
},
{
Expand Down Expand Up @@ -6745,7 +6745,7 @@
"id": "s6",
"depth": 1,
"content": [
"Author contributions"
"AUTHOR CONTRIBUTIONS"
]
},
{
Expand All @@ -6762,7 +6762,7 @@
"id": "s7",
"depth": 1,
"content": [
"Declaration of interests"
"DECLARATION OF INTERESTS"
]
},
{
Expand All @@ -6779,7 +6779,7 @@
"id": "s8",
"depth": 1,
"content": [
"Supplemental information"
"SUPPLEMENTAL INFORMATION"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5021,7 +5021,7 @@
"id": "s1",
"depth": 1,
"content": [
"Introduction"
"INTRODUCTION"
]
},
{
Expand Down Expand Up @@ -5279,7 +5279,7 @@
"id": "s2",
"depth": 1,
"content": [
"Materials and methods"
"MATERIALS AND METHODS"
]
},
{
Expand Down Expand Up @@ -5563,7 +5563,7 @@
"id": "s2b7",
"depth": 3,
"content": [
"Ltpa"
"LTPA"
]
},
{
Expand Down Expand Up @@ -5836,7 +5836,7 @@
"id": "s3",
"depth": 1,
"content": [
"Results"
"RESULTS"
]
},
{
Expand Down Expand Up @@ -6339,7 +6339,7 @@
"id": "s4",
"depth": 1,
"content": [
"Discussion"
"DISCUSSION"
]
},
{
Expand Down
17 changes: 3 additions & 14 deletions src/codecs/jats/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import stencila, { isA, ThingTypes } from '@stencila/schema'
import crypto from 'crypto'
import { dropLeft, takeLeftWhile } from 'fp-ts/lib/Array'
import fs from 'fs-extra'
import { sentenceCase } from 'sentence-case'
import { isDefined } from '../../util'
import { ensureArticle } from '../../util/content/ensureArticle'
import { ensureBlockContent } from '../../util/content/ensureBlockContent'
Expand Down Expand Up @@ -573,7 +572,8 @@ export function decodeAbstract(
!(
block.type === 'Heading' &&
block.content.length === 1 &&
block.content[0] === 'Abstract'
typeof block.content[0] === 'string' &&
block.content[0].toUpperCase() === 'ABSTRACT'
),
)
}
Expand Down Expand Up @@ -1877,9 +1877,6 @@ function decodeAppendix(
* implies a nested section. This is more likely to ensure conformance with
* the following rule if the document is encoded to HTML:
* https://dequeuniversity.com/rules/axe/3.5/heading-order
*
* For consistency, across documents all caps titles are converted to
* sentence case.
*/
function decodeHeading(
elem: xml.Element,
Expand All @@ -1891,20 +1888,12 @@ function decodeHeading(
ancestorElem?.name === 'sec' || ancestorElem?.name === 'app'
? [sectionDepth, sectionId]
: [sectionDepth + 1, undefined]
let content = decodeInlineContent(elem.elements ?? [], state)
const content = decodeInlineContent(elem.elements ?? [], state)

if (depth === undefined || Number.isNaN(depth)) {
depth = 1
}

if (
content.length === 1 &&
typeof content[0] === 'string' &&
content[0].toUpperCase() === content[0]
) {
content = [sentenceCase(content[0])]
}

return [
stencila.heading({
content,
Expand Down

0 comments on commit b58e98c

Please sign in to comment.