List intendation

This commit is contained in:
Johannes Zillmann 2024-06-16 23:29:20 -06:00
parent c39f410d76
commit 71b31c2fb5
6 changed files with 58 additions and 49 deletions

View File

@ -105,17 +105,17 @@ Also los!
Und Untergruppen: Und Untergruppen:
- Eintrag 1 - Eintrag 1
- Sub Eintrag 1.1, aber mit so langem Text, das er umbricht. Wirklich, wirklich lang. Breche du - Sub Eintrag 1.1, aber mit so langem Text, das er umbricht. Wirklich, wirklich lang. Breche du
Zeile. Na los. Na endlich. Vielleicht sollt ich das auf 3 Zeilen erweitern? Na ja, schaden kann Zeile. Na los. Na endlich. Vielleicht sollt ich das auf 3 Zeilen erweitern? Na ja, schaden kann
es ja nicht. Also los! es ja nicht. Also los!
- Sub Eintrag 1. - Sub Eintrag 1.2
- Eintrag 2 - Eintrag 2
- Sub Eintrag 2. - Sub Eintrag 2.1
Und eine mit bullets: Und eine mit bullets:
- Eintrage 1 Eintrage 1
- Eintrage 2 Eintrage 2
Gemixt: Gemixt:
@ -147,27 +147,26 @@ Zwei aufeinander folgende Listen:
- Zwote 1 - Zwote 1
- Zwote 2 - Zwote 2
Liste mit drei Levels: Liste mit drei Levels:
- Erster Level 1 - Erster Level 1
- Zwoter Level 1.1, aber mit so langem Text, das er umbricht. Wirklich, wirklich lang. Breche du - Zwoter Level 1.1, aber mit so langem Text, das er umbricht. Wirklich, wirklich lang. Breche du
Zeile. Na los. Na endlich. Vielleicht sollt ich das auf 3 Zeilen erweitern? Na ja, schaden kann Zeile. Na los. Na endlich. Vielleicht sollt ich das auf 3 Zeilen erweitern? Na ja, schaden kann
es ja nicht. Also los! es ja nicht. Also los!
- 3ter Level 1.1. - 3ter Level 1.1.1
- 3ter Level 1.1.2, aber mit so langem Text, das er umbricht. Wirklich, wirklich lang. Breche - 3ter Level 1.1.2, aber mit so langem Text, das er umbricht. Wirklich, wirklich lang. Breche
du Zeile. Na los. Na endlich. Vielleicht sollt ich das auf 3 Zeilen erweitern? Na ja, schaden du Zeile. Na los. Na endlich. Vielleicht sollt ich das auf 3 Zeilen erweitern? Na ja, schaden
kann es ja nicht. Also los! kann es ja nicht. Also los!
- Zwoter Level 1. - Zwoter Level 1.2
- Zwoter Level 1. - Zwoter Level 1.3
- 3ter Level 1.3. - 3ter Level 1.3.1
- Erster Level 2 - Erster Level 2
Und nun nummeriert mit un-nummerierten Sub-Leveln: Und nun nummeriert mit un-nummerierten Sub-Leveln:
1. Eintrag 1 1. Eintrag 1
- Eintrag 1. - Eintrag 1.1
- Eintrag 1. - Eintrag 1.2
2. Eintrag 2 2. Eintrag 2
Und jetzt eine Liste, die übergangslos aus einem zwei-zeiligen Paragraphen folgt. Mal sehen ob Und jetzt eine Liste, die übergangslos aus einem zwei-zeiligen Paragraphen folgt. Mal sehen ob

View File

@ -2339,47 +2339,47 @@ Appendix M: Summary of the six step improvement process for transfer of care
**1** **1**
• **Start out (page 10)** • **Start out (page 10)**
• Refer to existing policies and procedures for transfers of care in your organisation • Refer to existing policies and procedures for transfers of care in your organisation
• Observe, measure and process map the current communication process • Observe, measure and process map the current communication process
• What does good look like? Compare your policy and communication process with the good practice checklist. • What does good look like? Compare your policy and communication process with the good practice checklist.
(Appendix B) (Appendix B)
**2** **2**
• **Define and scope (page 13)** • **Define and scope (page 13)**
• Begin to answer the three questions of the model for improvement (Appendix C) • Begin to answer the three questions of the model for improvement (Appendix C)
• Set your project aim and scope and link this to your organisational big issues on a driver diagram (page 22) • Set your project aim and scope and link this to your organisational big issues on a driver diagram (page 22)
• Engage staff, patients, clients and residents using patient stories and evidence from useful resources • Engage staff, patients, clients and residents using patient stories and evidence from useful resources
• Choose your project team, include senior and frontline staff and patients/clients/residents • Choose your project team, include senior and frontline staff and patients/clients/residents
• Document your project plan (Appendix F) and use the sustainaiblity guide to think about long term impact of change • Document your project plan (Appendix F) and use the sustainaiblity guide to think about long term impact of change
**3** **3**
• **Measure and understand (page 19)** • **Measure and understand (page 19)**
• Choose and define your outcomes and process measures, collect baseline data and display on run or SPC charts • Choose and define your outcomes and process measures, collect baseline data and display on run or SPC charts
**4** **4**
• **Design and plan (page 24)** • **Design and plan (page 24)**
• Design your standard transfer of care template and test using Plan Do Study Act (PDSA) cycles (Appendix I & J) • Design your standard transfer of care template and test using Plan Do Study Act (PDSA) cycles (Appendix I & J)
• Use dot voting to define your minimum data set (Appendix G) • Use dot voting to define your minimum data set (Appendix G)
• Select a standardised communication tool (e.g. SBAR) to organise your minimum data set • Select a standardised communication tool (e.g. SBAR) to organise your minimum data set
• Generate and test other change ideas using the good practice checklist (Appendix B) and examples (Appendix K) • Generate and test other change ideas using the good practice checklist (Appendix B) and examples (Appendix K)
• Choose process measures (Appendix H) collect data and display on run or SPC charts • Choose process measures (Appendix H) collect data and display on run or SPC charts
**5** **5**
• **Pilot and implement (page 34)** • **Pilot and implement (page 34)**
• Document your new standardised transfer of care process • Document your new standardised transfer of care process
• Plan your tests for implementation using PDSA cycles. Plan training, measurement, resources & stakeholder • Plan your tests for implementation using PDSA cycles. Plan training, measurement, resources & stakeholder
engagement. (Appendix I & J) engagement. (Appendix I & J)
• Consider 'flexible standardisation' and spread good practice to other teams, departments and organisations • Consider 'flexible standardisation' and spread good practice to other teams, departments and organisations
**6** **6**
• **Sustain and share (page 38)** • **Sustain and share (page 38)**
• Use the sustainability guide to ensure your changes will be sustained • Use the sustainability guide to ensure your changes will be sustained
• Celebrate and spread your success through conferences, posters, journal articles etc. (Appendix L) • Celebrate and spread your success through conferences, posters, journal articles etc. (Appendix L)
### Product timeline ### Product timeline

View File

@ -5,6 +5,7 @@ export default class Item {
page: number; page: number;
data: object; data: object;
uuid: string; uuid: string;
listLevel = 0;
tokenTypes: TokenType[] = []; tokenTypes: TokenType[] = [];
constructor(page: number, data: object, tokenTypes: TokenType[] = [], uuid: string = uuidv4()) { constructor(page: number, data: object, tokenTypes: TokenType[] = [], uuid: string = uuidv4()) {

View File

@ -61,20 +61,25 @@ export function lineToText(lineItems: Item[], blockTypes: TextType[]) {
}; };
let lastLineItem: Item = null; let lastLineItem: Item = null;
lineItems.forEach((lineItem, lineIndex) => { lineItems.forEach((lineItem, indexInLine) => {
const words = toWords(lineItem.data['str']); const words = toWords(lineItem.data['str']);
words.forEach((word, wordIndex) => { words.forEach((word, wordIndex) => {
if (indexInLine === 0 && wordIndex === 0) {
if (lineItem.listLevel) {
word = ' '.repeat(lineItem.listLevel * 2) + word;
}
}
const wordFormat = lineItem.tokenTypes[0]; // bold, oblique, footnote etc... const wordFormat = lineItem.tokenTypes[0]; // bold, oblique, footnote etc...
if (openFormat && (!wordFormat || wordFormat !== openFormat)) { if (openFormat && (!wordFormat || wordFormat !== openFormat)) {
closeFormat(); closeFormat();
} }
if ( if (
(wordIndex > 0 || lineIndex > 0) && (wordIndex > 0 || indexInLine > 0) &&
!(wordFormat && attachWithoutWhitespace(wordFormat)) && !(wordFormat && attachWithoutWhitespace(wordFormat)) &&
!isPunctationCharacter(word) !isPunctationCharacter(word)
) { ) {
let insertWhitespace = true; let insertWhitespace = true;
if (lineIndex > 0 && wordIndex == 0) { if (indexInLine > 0 && wordIndex == 0) {
const xDistance = lineItem.data['x'] - lastLineItem.data['x'] - lastLineItem.data['width']; const xDistance = lineItem.data['x'] - lastLineItem.data['x'] - lastLineItem.data['width'];
if (xDistance < 2 && !lastLineItem.data['str']?.endsWith(' ') && !lineItem.data['str']?.startsWith(' ')) { if (xDistance < 2 && !lastLineItem.data['str']?.endsWith(' ') && !lineItem.data['str']?.startsWith(' ')) {
insertWhitespace = false; insertWhitespace = false;
@ -98,7 +103,7 @@ export function lineToText(lineItems: Item[], blockTypes: TextType[]) {
text += word; text += word;
} }
}); });
if (openFormat && (lineIndex == lineItems.length - 1 || firstFormat(lineItems[lineIndex + 1]) !== openFormat)) { if (openFormat && (indexInLine == lineItems.length - 1 || firstFormat(lineItems[indexInLine + 1]) !== openFormat)) {
closeFormat(); closeFormat();
} }
lastLineItem = lineItem; lastLineItem = lineItem;

View File

@ -138,3 +138,7 @@ export function majorityElement<T>(items: Item[], extract: (item: Item) => T): T
} }
return extract(items[maj]); return extract(items[maj]);
} }
export function isGreaterWithTolerance(num1: number, num2: number, tolerance = 0.01) {
return num1 - num2 > tolerance;
}

View File

@ -3,7 +3,7 @@ import ItemResult from '../ItemResult';
import ItemTransformer from './ItemTransformer'; import ItemTransformer from './ItemTransformer';
import TransformContext from './TransformContext'; import TransformContext from './TransformContext';
import LineItemMerger from '../debug/LineItemMerger'; import LineItemMerger from '../debug/LineItemMerger';
import { groupByBlock, groupByLine } from '../support/groupingUtils'; import { groupByBlock, groupByLine, isGreaterWithTolerance } from '../support/groupingUtils';
import { TextType, toBlockType } from '../text-types'; import { TextType, toBlockType } from '../text-types';
import { isListItem, isNumberedListItem } from '../support/stringFunctions'; import { isListItem, isNumberedListItem } from '../support/stringFunctions';
@ -40,7 +40,7 @@ export default class DetectListLevels extends ItemTransformer {
const x = firstItem.data['x']; const x = firstItem.data['x'];
if (lastItemX) { if (lastItemX) {
if (isLineItem) { if (isLineItem) {
if (x > lastItemX) { if (isGreaterWithTolerance(x, lastItemX)) {
currentLevel++; currentLevel++;
xByLevel[x] = currentLevel; xByLevel[x] = currentLevel;
} else if (x < lastItemX) { } else if (x < lastItemX) {
@ -54,10 +54,10 @@ export default class DetectListLevels extends ItemTransformer {
xByLevel[x] = 0; xByLevel[x] = 0;
} }
if (currentLevel > 0) { if (currentLevel > 0) {
lineItems[0].data['str'] = ' '.repeat(currentLevel * 3) + lineItems[0].data['str']; lineItems[0].listLevel = currentLevel;
modifiedBlock = true; modifiedBlock = true;
if (isOverflowLine) { if (isOverflowLine) {
lineItems[0].data['str'] = ' ' + lineItems[0].data['str']; // TODO mark line so it can be indented as well ?
} }
} }
if (!isOverflowLine) { if (!isOverflowLine) {