MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Plugins (https://www.mobileread.com/forums/forumdisplay.php?f=268)
-   -   [Plugin] Proselint - English style checker (https://www.mobileread.com/forums/showthread.php?t=309489)

Doitsu 07-28-2018 06:05 AM

[Plugin] Proselint - English style checker
 
1 Attachment(s)
Released: October 5, 2019
Current Version: "0.1.1"

This plugin is a simple proselint-based style checker.

System requirements:

This plugin requires Sigil 0.9.5 or higher.

Installation:

1. Select Manage Plugins from the Plugins menu and select Use Bundled Python, if it isn't already selected.

2. Click Add Plugin and select Proselint_v0.1.1.zip. This will install the Proselint plugin, which you can select via Plugins > Valdidation > Proselint.

Settings:

You can disable Proselint checks by editing .proselintrc, which is located in the proselint subfolder.

If you have a Windows machine, you can use the following commands to display the proselint plugin subfolder:
  1. Press Windows+R (Run).
  2. Copy and paste %USERPROFILE%\AppData\Local\sigil-ebook\sigil\plugins\Proselint\proselint and press Enter.

For example, if you don't want Proselint to complain about 'very,' change the following entry from:

Code:

        "weasel_words.very"            : true
to

Code:

        "weasel_words.very"            : false
License: GNU General Public License v3 (GPL-3)

BetterRed 09-19-2019 10:02 PM

How can I add or remove an individual item - I tried editing a misc.py file by commenting out an entry and adding an additional one, they didn't seem to have any effect. The first continued to be reported, the second one wasn't reported.

BR

Doitsu 09-20-2019 02:09 AM

Quote:

Originally Posted by BetterRed (Post 3892515)
How can I add or remove an individual item - I tried editing a misc.py file by commenting out an entry and adding an additional one, they didn't seem to have any effect.

Please be more specific. Which of the python files in the misc folder did you edit and what did you change?

BetterRed 09-20-2019 03:09 AM

Quote:

Originally Posted by Doitsu (Post 3892591)
Please be more specific. Which of the python files in the misc folder did you edit and what did you change?

I have SIGIL_PREFS_DIR=C:\_AppData\Sigil\Prefs

So this one C:\_AppData\Sigil\Prefs\plugins\Proselint\proselin t\checks\archaism\misc.py as a simple test - begat was reported, woke wasn't.

Spoiler:
# -*- coding: utf-8 -*-
"""Archaism.

---
layout: post
source: Garner's Modern American Usage
source_url: http://bit.ly/1T4alrY
title: archaism
date: 2014-06-10 12:31:19
categories: writing
---

Archaism.

"""
from proselint.tools import existence_check, memoize


@memoize
def check(text):
"""Check the text."""
err = "archaism.misc"
msg = u"'{}' is archaic."

archaisms = [
"alack",
"anent",
# "anon",
#"begat",
"belike",
"betimes",
"boughten",
"brocage",
"brokage",
"camarade",
"chiefer",
"chiefest",
"Christiana",
"completely obsolescent",
"cozen",
"divers",
"deflexion",
"durst",
"fain",
"forsooth",
"foreclose from",
"haply",
"howbeit",
"illumine",
"in sooth",
"maugre",
"meseems",
"methinks",
"nigh",
"peradventure",
"perchance",
"saith",
"shew",
"sistren",
"spake",
"to wit",
"verily",
"whilom",
"withal",
"woke",
"wot",
"enclosed please find",
"please find enclosed",
"enclosed herewith",
"enclosed herein",
"inforce",
"ex postfacto",
"foreclose from",
"forewent",
"for ever",
# "designer", when used to mean a plotter against Christ
# "demean", when used to mean "to behave" in legal contexts
# "by the bye", # variant, modern is "by the by"
# "comptroller" # in British English
# "abortive" Abortive is archaic in reference to abortions of fetuses,
# except in the sense “causing an abortion.”
]

return existence_check(text, archaisms, err, msg, join=True)

Doitsu 09-20-2019 04:03 AM

Quote:

Originally Posted by BetterRed (Post 3892515)
How can I add or remove an individual item[...]

Since Proselint apparently caches rule files in:

C:\Users\<your user name>\.cache\proselint


you'll have to delete the cache folder after rule file updates.

BetterRed 09-20-2019 04:41 AM

Quote:

Originally Posted by Doitsu (Post 3892615)
Since Proselint apparently caches rule files in:

C:\Users\<your user name>\.cache\proselint


you'll have to delete the cache folder after rule file updates.

Thanks - I'll give it a whirl tomorrow.

BR

BetterRed 09-20-2019 10:19 PM

Deleting the cache did the trick.

Is there a syntax spec for the rules in the misc.py files. Nothing leapt out at me at GitHub. I know it's python but... the rules themselves are collections of data.

BR

Doitsu 09-21-2019 05:08 AM

Quote:

Originally Posted by BetterRed (Post 3892988)
Is there a syntax spec for the rules in the misc.py files. Nothing leapt out at me at GitHub. I know it's python but... the rules themselves are collections of data.

I haven't found rule specs either. You might want to ask the author about it.

BetterRed 09-21-2019 07:22 AM

Quote:

Originally Posted by Doitsu (Post 3893046)
I haven't found rule specs either. You might want to ask the author about it.

I'll keep that until I really need it,

Couple of suggestions/requests

would an option to check multiple/all files be possible, checking file by file doesn't make much sense to me.

when an error flags a specific word or or phrase, would it be possible to select/highlight the word/phrase in the code - like the spell checker does, currently the insertion point is positioned to the beginning of the error, which is hard to see, I have to use ctrl+shift+→ to highlight what follows.

BR

Doitsu 09-21-2019 07:37 AM

Quote:

Originally Posted by BetterRed (Post 3893062)
would an option to check multiple/all files be possible, checking file by file doesn't make much sense to me.

If you want the plugin to check all files, simply click the Text folder before running the plugin.

Quote:

Originally Posted by BetterRed (Post 3893062)
when an error flags a specific word or or phrase, would it be possible to select/highlight the word/phrase in the code - like the spell checker does, currently the insertion point is positioned to the beginning of the error, which is hard to see, I have to use ctrl+shift+→ to highlight what follows.

Unfortunately, the Sigil API doesn't have any functions for text highlighting.

KevinH 09-21-2019 09:29 AM

That is correct. Sigil plugin is a file level api. A validation plugin should be able to move you to the exact file offset start of the error.

If this is done via a edit plugin, you can of course add a highlight css class and wrap a span around anything to highlight its contents to the user.

Kevin

Doitsu 09-21-2019 09:49 AM

Quote:

Originally Posted by KevinH (Post 3893094)
That is correct. Sigil plugin is a file level api. A validation plugin should be able to move you to the exact file offset start of the error.

FYI: the Proselint plugin is a validation plugin, and clicking a message will move the cursor to the beginning of the word or phrase that was flagged.

BetterRed 09-21-2019 06:03 PM

Quote:

Originally Posted by Doitsu (Post 3893067)
If you want the plugin to check all files, simply click the Text folder before running the plugin.

:o doh :smack:

Quote:

Originally Posted by Doitsu (Post 3893067)
Unfortunately, the Sigil API doesn't have any functions for text highlighting.

Quote:

Originally Posted by KevinH (Post 3893094)
That is correct. Sigil plugin is a file level api. A validation plugin should be able to move you to the exact file offset start of the error.

Quote:

Originally Posted by Doitsu (Post 3893099)
FYI: the Proselint plugin is a validation plugin, and clicking a message will move the cursor to the beginning of the word or phrase that was flagged.

My difficulty is finding the insertion cursor. No worries, tapping ctrl+shift+→ to highlight the errant text is second nature to me. Or I could get a thicker caret :)

BR


All times are GMT -4. The time now is 08:44 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.