Skip to content

Commit

Permalink
Merge branch 'master' into rules-page-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
elijah-potter committed Mar 7, 2025
2 parents 8fe14a5 + 9c1d006 commit 36ea05b
Show file tree
Hide file tree
Showing 14 changed files with 524 additions and 45 deletions.
2 changes: 0 additions & 2 deletions harper-core/dictionary.dict
Original file line number Diff line number Diff line change
Expand Up @@ -34332,9 +34332,7 @@ nympho/1S
nymphomania/1M
nymphomaniac/15SM
nymphs/14
o/15+
o'clock/
o'er/+
oaf/1SM
oafish/5PY
oafishness/1M
Expand Down
53 changes: 52 additions & 1 deletion harper-core/src/linting/phrase_corrections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,13 @@ pub fn lint_group() -> LintGroup {
["day and age"],
"Use `day and age` for referring to the present time.",
"Corrects the eggcorn `day in age` to `day and age`, which properly means the current era or time period."
)
),
"NerveRacking" => (
["nerve racking", "nerve wracking", "nerve wrecking", "nerve-wracking", "nerve-wrecking"],
["nerve-racking"],
"Use `nerve-racking` for something that causes anxiety or tension.",
"Corrects common misspellings and missing hyphen in `nerve-racking`."
),
});

group.set_all_rules_to(Some(true));
Expand Down Expand Up @@ -780,4 +786,49 @@ mod tests {
"This seems like a blanket statement and I have not found any info to back up whether PyJWT is affected.",
);
}

#[test]
fn detect_nerve_wracking_hyphen() {
assert_suggestion_result(
"We've gone through several major changes / upgrades to atlantis, and it's always a little bit nerve-wracking because if we mess something up we ...",
lint_group(),
"We've gone through several major changes / upgrades to atlantis, and it's always a little bit nerve-racking because if we mess something up we ...",
);
}

#[test]
fn detect_nerve_wrecking_hyphen() {
assert_suggestion_result(
"The issue happens to me on a daily basis, and it is nerve-wrecking because I become unsure if I have actually saved the diagram, but every time ...",
lint_group(),
"The issue happens to me on a daily basis, and it is nerve-racking because I become unsure if I have actually saved the diagram, but every time ...",
);
}

#[test]
fn detect_nerve_wracking_no_hyphen() {
assert_suggestion_result(
"Very nerve wracking landing in an unfamiliar mountainous airport in dead of night with no radar to show surrounding terrain.",
lint_group(),
"Very nerve-racking landing in an unfamiliar mountainous airport in dead of night with no radar to show surrounding terrain.",
);
}

#[test]
fn detect_nerve_wrecking_no_hyphen() {
assert_suggestion_result(
"I appreciate any kind of help since this is kind of nerve wrecking.",
lint_group(),
"I appreciate any kind of help since this is kind of nerve-racking.",
);
}

#[test]
fn detect_nerve_racking_no_hyphen() {
assert_suggestion_result(
"It's nerve racking to think about it because I have code inside the callback that resolves the member and somehow I feel like it's so ..",
lint_group(),
"It's nerve-racking to think about it because I have code inside the callback that resolves the member and somehow I feel like it's so ..",
);
}
}
10 changes: 10 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ test-harperjs: build-harperjs
yarn install
yarn start

dev-wp: build-harperjs
#! /bin/bash

set -eo pipefail

cd "{{justfile_directory()}}/packages/wordpress-plugin"
yarn install -f
yarn run wp-now start &
yarn start

# Build the WordPress plugin
build-wp: build-harperjs
#! /bin/bash
Expand Down
42 changes: 42 additions & 0 deletions packages/web/demo_wp_blueprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"preferredVersions": {
"php": "8.0",
"wp": "6.7"
},
"meta": {
"title": "Demo of Harper for WordPress",
"description": "Harper is a grammar checker for people who want to write, without any fuss.",
"author": "elijah-potter",
"categories": []
},
"landingPage": "/wp-admin/post.php?post=4&action=edit",
"steps": [
{
"step": "login",
"username": "admin",
"password": "password"
},
{
"step": "installPlugin",
"pluginData": {
"resource": "url",
"url": "https://github.com/Automattic/harper/releases/download/v0.24.0/harper.zip"
},
"options": {
"activate": true
}
},
{
"step": "installTheme",
"themeData": {
"resource": "wordpress.org/themes",
"slug": "twentytwentyfour"
}
},
{
"step": "runPHP",
"code": "<?php require_once 'wordpress/wp-load.php'; wp_insert_post(array('post_title' => 'Harper, in WordPress', 'post_content' => '<!-- wp:paragraph --><p><strong>Click on the Harper button on the top right of this page to get started.</strong></p><!-- /wp:paragraph --><!-- wp:paragraph --><p>Writing on the web can be scary. Theres a lot of competition for traffic and even a small grammatical mstake can be costly to your reputation and search rankings.</p><!-- /wp:paragraph --><!-- wp:paragraph --><p>That\\'s why we created Harper: an plugin to save you the embarassment. it can fix typos, serial commas and overall just make your life better.</p><!-- /wp:paragraph --><!-- wp:paragraph --><p>All that while respecting your privacy. You data should never leave Wordpress until you hit \"Publish\".</p><!-- /wp:paragraph -->'));"
}
]
}
2 changes: 1 addition & 1 deletion packages/web/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
>, Neovim,
<a href="https://github.com/Stef16Robbe/harper_zed">Zed</a>
and
<a href="/obsidian">Obsidian</a> integration is amazing.
<a href="/docs/integrations/obsidian">Obsidian</a> integration is amazing.
</span>

<img
Expand Down
33 changes: 33 additions & 0 deletions packages/web/src/routes/docs/contributors/wordpress/+page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# WordPress Plugin

This page will describe most of what you need to know to build and develop the WordPress plugin locally.
You do NOT need to have a WordPress installation on your machine (or hosted on a server, for that matter) to work on the Harper plugin.

Make sure you read the [introduction to contributing](./introduction) before opening a pull request.

## Notes

- The plugin does not have any kind of automated testing.
- You can look at the project's [`justfile`](https://github.com/Automattic/harper/blob/master/justfile) to see exactly what running the `just` recipes below do.

## Prerequisites

Make sure to [set up your environment](./environment).

## Running the Plugin on Your Machine

You should have already run `just setup` to prepare your environment.
All you need to do from here is run `just dev-wp`. This will:

- Download a local copy of the WordPress Playground to your machine
- Build and start watching for changes to the plugin code.
- Run WordPress, mounting the build directory to the Playground instance.

When you make changes to the plugin code, it will be rebuild and you will be able to reload the WordPress page to see your change.

:::info[Remember]
The Harper WordPress plugin only works on the Gutenberg editor.
You will need to draft or edit a post to see the option to open the sidebar.
:::

![Open the Harper Sidebar](/images/harper_wp_sidebar_button.png)
31 changes: 31 additions & 0 deletions packages/web/src/routes/docs/integrations/wordpress/+page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<script>
import {Button} from "flowbite-svelte"
</script>

# Harper for WordPress

Harper is now ready to be installed to the nearest WordPress site near you.
It's still early days, so expect bugs.

Not ready to install it just yet?
Visit our online demo to try writing a blog post with Harper.

<Button href='/wpdemo' target="_blank">Go to the Demo</Button>

## Your Voice Means Something

![A screenshot of the Harper WordPress Demo](/images/harper_wp_playground_screenshot.png)

Harper checks your work for grammatical errors. That's it.

Other grammar checkers try to strip out everything that makes your writing unique.
We believe you should have the freedom to write what's on your mind, not what an LLM thinks you want to hear.
Harper is designed to be fast and **get out of the way**.

<Button href='/wpdemo' target="_blank">Go to the Demo</Button>

## Installation

For now, can install Harper into WordPress by downloading `harper.zip` from [GitHub releases](https://github.com/Automattic/harper/releases/latest) and uploading it to your site.

Harper will be coming to the WordPress.org plugin directory soon. Hang tight!
9 changes: 9 additions & 0 deletions packages/web/src/routes/wpdemo/+page.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { redirect } from '@sveltejs/kit';
import blueprint from '../../../demo_wp_blueprint.json?raw';

const base64Blueprint = btoa(blueprint);
const playgroundUrl = `https://playground.wordpress.net/?mode=seamless#${base64Blueprint}`;

export function load() {
redirect(302, playgroundUrl);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions packages/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export default defineConfig({
title: 'Obsidian',
to: '/docs/integrations/obsidian'
},
{
title: 'WordPress',
to: '/docs/integrations/wordpress'
},
{
title: 'Language Server',
to: '/docs/integrations/language-server'
Expand Down Expand Up @@ -126,6 +130,10 @@ export default defineConfig({
title: 'Visual Studio Code',
to: '/docs/contributors/visual-studio-code'
},
{
title: 'WordPress',
to: '/docs/contributors/wordpress'
},
{
title: 'Reviewing Pull Requests',
to: '/docs/contributors/review'
Expand Down
10 changes: 2 additions & 8 deletions packages/wordpress-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
This repository contains the WordPress plugin for [Harper](https://writewithharper.com).
It is a work-in-progress. Here be dragons!

## Compiling from Source
## Contributing

The Harper plugin uses the standard build tooling available for WordPress plugins.

```bash
yarn install # Install dependencies
yarn build # Build the plugin
yarn plugin-zip # Package the plugin into an installable ZIP file
```
Refer to [the online documentation](https://writewithharper.com/docs/contributors/wordpress) for instruction to contribute to the plugin.
3 changes: 2 additions & 1 deletion packages/wordpress-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
"scripts": {
"build": "wp-scripts build --webpack-copy-php",
"packages-update": "wp-scripts packages-update",
"plugin-zip": "wp-scripts plugin-zip && mv wordpress-plugin.zip harper.zip && echo Renamed to harper.zip",
"plugin-zip": "zip harper.zip build harper.php screenshot.png -r",
"start": "wp-scripts start --webpack-copy-php"
},
"devDependencies": {
"@wordpress/eslint-plugin": "^22.2.0",
"@wordpress/scripts": "^30.9.0",
"@wp-now/wp-now": "^0.1.74",
"eslint": "^8.57.0",
"prettier": "^3.4.2",
"typescript": "^5.7.3"
Expand Down
Loading

0 comments on commit 36ea05b

Please sign in to comment.