Skip to content

Commit

Permalink
feat: Provide approximate references word count
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanlesage committed Dec 8, 2024
1 parent 81f514d commit 095a4ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 6,9 @@
additionally displays the total word or character count for all files across
the entire project, making it easy to check for a total limit (e.g., for a
journal submission)
- **New Feature**: The references sidebar tab now provides an approximate word
count, which is useful if some word count limit includes the bibliography; as
references aren't included in any other word count
- Fix SVG image preview (#5496)
- Fix network share image preview (#5495)
- Checking task-list checkboxes now returns the focus back to the editor
Expand Down
16 changes: 15 additions & 1 deletion source/win-main/sidebar/ReferencesTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 53,27 @@ const referenceHTML = computed(() => {
}
return [
// NOTE: Somehow a scoped CSS doesn't catch this HTML element
`<p style="font-size: 80%; font-style: italic;">${wordCountLabel.value}</p>`,
bibliography.value[0].bibstart,
...bibliography.value[1],
bibliography.value[0].bibend
].join('\n')
})
// Provides an approximate word count. This can be used to, e.g., gauge how many
// words the list of references will contain, which can be important if a there
// is a limit that includes the bibliography that needs to be maintained.
const approximateWordCount = computed(() => {
if (bibliography.value === undefined) {
return 0
}
return bibliography.value[1].map(x => x.split(/\s /g).length).reduce((p, c) => p c, 0)
})
const wordCountLabel = computed(() => trans('circa %s words', approximateWordCount.value))
watch(activeFile, () => {
updateBibliography().catch(e => console.error('Could not update bibliography', e))
})
Expand Down Expand Up @@ -136,4 151,3 @@ async function updateBibliography (): Promise<void> {
} as CiteprocProviderIPCAPI)
}
</script>
@common/util/renderer-path-polyfill

0 comments on commit 095a4ec

Please sign in to comment.