-
-
Notifications
You must be signed in to change notification settings - Fork 565
Meta: Introduce linting tools #1198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Allows to reuse partial word lists for different plugins
If I don't find a suitable alternative, I'll write this better and then publish it on npm or pull it as a dependency from my GH
- Add more commit format examples - Break guidelines about PR, issues and commits into their own section. - This prepares the section for adding info about using the linting tools
Includes sections broken off from README
|
Great work here! I went ahead and created a Nix package & devshell along with a CI check action (which I'll have to fix). |
|
Thank you! |
Adds a Nix flake which contains remark with plugins as a Nix package, along with a dev shell.
Checks the whole repo using the Nix lint package.
Fails with exit code 1 even on warnings. Makes it easy to catch errors in CI.
|
I think I've fixed CI now, sorry for the long wait. I've tried to run -| exec | executes a shell command | command (supports rules, see [below]({{< relref "#executing-with-rules" >}})) |
+| exec | executes a shell command | command (supports rules, see \[below]\({{< relref "#executing-with-rules" >}})) |The thing is I don't even know why that was there, could've just used the #link directly. I'll check if anything else is sus and update this comment. More examples -{{</ callout >}}
+{{\</ callout >}}-[module options](https://search.nixos.org/options?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=hyprland).
-
+[module options](https://search.nixos.org/options?channel=unstable\&from=0\&size=50\&sort=relevance\&type=packages\&query=hyprland). |
|
Thank you, I'll look into it |
|
@fufexan > [!NOTE]
> For binding keys without a modkey, leave it empty:
>
> ```ini
> bind = , Print, exec, grim
> ```instead of: {{< callout type=info >}}
For binding keys without a modkey, leave it empty:
```ini
bind = , Print, exec, grim
```
{{< /callout >}}They render pretty much the same (hugo shortcode above, native below):
|
|
I didn't know GFM was supported. We could do that, sure. |
+ Rename `fix` command to `fixall`
Neither did I 😄 I made this perl script to convert all hugo callouts shortcodes into native GMF: #!/usr/bin/env perl
use strict;
use warnings;
use File::Find;
# Mapping from hugo callout type -> GFM alert type
my %map = (
info => 'NOTE',
warning => 'WARNING',
important => 'IMPORTANT',
);
sub transform {
my ($text) = @_;
$text =~ s{
\{\{<\s*callout(?:\s+type=(\w+))?\s*>\}\} # opening shortcode
(.*?) # body
\{\{<\s*/?\s*callout\s*>\}\} # closing shortcode (forgiving of malformed closing tags)
}{
my $type = $1 // 'warning';
my %map = (info=>'NOTE', warning=>'WARNING', important=>'IMPORTANT');
my $hdr = $map{lc $type} // uc($type);
my $body = $2;
# Trim leading/trailing newlines inside the callout
$body =~ s/^\n+//;
$body =~ s/\n+$//;
# If the very first line is empty, drop it
$body =~ s/^\s*\n//;
# Prefix all lines (including blanks) with "> "
$body =~ s/^/> /mg;
"> [!$hdr]\n$body"
}egsx;
return $text;
}
sub process_file {
my ($file) = @_;
return unless $file =~ /\.md$/i;
local $/ = undef;
open my $fh, '<', $file or die "Cannot open $file: $!";
my $content = <$fh>;
close $fh;
my $new = transform($content);
if ($new ne $content) {
open my $out, '>', $file or die "Cannot write $file: $!";
print $out $new;
close $out;
print "Transformed: $file\n";
}
}
my $root = shift @ARGV // 'content';
find(
{
wanted => sub { process_file($File::Find::name) if -f },
no_chdir => 1,
},
$root
);Diffs look ok to me, but please try it out on your end too, just to make sure it's all good. you can run it fro m the hugo root like so:
|
Removed by mistake during merge
|
I think this could cause generally cause problems with custom syntax. |
Ideally we'd wanna reduce hugo-specific syntax to a minimum. I'm not familiar with .mdx, so could you please expand on how you intended to use it? |
|
Nevermind, I remark lint should support mdx out of the box. |

This PR introduces tools to perform linting on Markdown docs using custom rules.
I opted to use remark with its remark-lint plugins.
Resolves #1193
If anyone wants to try this out:
To lint the whole
content/folder:cd lint pnpm i pnpm run checkallOr just one file:
TODO:
pnpm run fix