Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP
  • Loading branch information
jdkato committed Nov 20, 2024
1 parent eb3917f commit 95d9474
Show file tree
Hide file tree
Showing 15 changed files with 172 additions and 193 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:
with:
fetch-depth: 0

- run: zip -r Hugo.zip Hugo -x "*.DS_Store"
- run: zip -r MDX.zip MDX -x "*.DS_Store"

- name: Upload style to release
uses: svenstaro/upload-release-action@v2
if: startsWith(github.ref, 'refs/tags/')
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: Hugo.zip
file: MDX.zip

test:
runs-on: ubuntu-latest
Expand All @@ -34,13 +34,17 @@ jobs:
- name: Install Deps
run: |
wget https://github.com/errata-ai/vale/releases/download/v${VALE_VERSION}/vale_${VALE_VERSION}_Linux_64-bit.tar.gz
mkdir bin && tar -xvzf vale_${VALE_VERSION}_Linux_64-bit.tar.gz -C bin
echo "./bin" >> $GITHUB_PATH
mkdir testdata/bin && tar -xvzf vale_${VALE_VERSION}_Linux_64-bit.tar.gz -C testdata/bin
echo "./testdata/bin" >> $GITHUB_PATH
./testdata/bin/vale -v
env:
VALE_VERSION: 3.3.0
VALE_VERSION: 3.9.1

- name: Features
run: |
zip -r Hugo.zip Hugo -x "*.DS_Store"
cd testdata && ../bin/vale sync && cd -
go test -v ./...
zip -r MDX.zip MDX -x "*.DS_Store"
cd testdata
./bin/vale sync
./bin/vale transform test.mdx > out.md
cd -
go run main.go
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Hugo.zip
MDX.zip
/testdata/styles
/testdata/out.md

# Binaries for programs and plugins
*.exe
Expand Down
10 changes: 0 additions & 10 deletions Hugo/.vale.ini

This file was deleted.

21 changes: 21 additions & 0 deletions MDX/.vale.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[formats]
mdx = md

[*.mdx]
CommentDelimiters = {/*, */}

# Exclude:
#
# `import ...`, `export ...`
# `<Component ... />`
# `<Component>...</Component>`
# `{ ... }`
TokenIgnores = (?sm)((?:import|export) .+?$), \
(?<!`)(<\w+ ?.+ ?\/>)(?!`), \
(<[A-Z]\w+>.+?<\/[A-Z]\w+>)

# Exclude:
#
# `<Component \n ... />`
BlockIgnores = (?sm)^(<\w+\n .*\s\/>)$, \
(?sm)^({.+.*})
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
all: test

zip:
zip -r Hugo.zip Hugo -x "*.DS_Store"
zip -r MDX.zip MDX -x "*.DS_Store"

sync:
cd testdata && vale sync && cd -
cd testdata && vale sync && vale transform test.mdx > out.md && cd -

test: zip sync
go test -v ./...
go run main.go
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Hugo
# MDX

A Vale configuration for Hugo-generated static sites.
A Vale configuration for sites using [MDX][1].

## Testing

```
$ make test
```

[1]: https://mdxjs.com
9 changes: 1 addition & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
module github.com/errata-ai/Hugo
module github.com/errata-ai/MDX

go 1.17

require github.com/google/go-cmdtest v0.4.0

require (
github.com/google/go-cmp v0.3.1 // indirect
github.com/google/renameio v0.1.0 // indirect
)
6 changes: 0 additions & 6 deletions go.sum

This file was deleted.

28 changes: 24 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
package main

import "os"
import (
"errors"
"os"
"path/filepath"
)

func cdf() int {
os.Chdir(os.Args[1])
return 0
func main() {
expected := filepath.Join("testdata", "in.md")
observed := filepath.Join("testdata", "out.md")

// Read the expected and observed files
expectedContent, err := os.ReadFile(expected)
if err != nil {
panic(err)
}

observedContent, err := os.ReadFile(observed)
if err != nil {
panic(err)
}

// Compare the contents of the files
if string(expectedContent) != string(observedContent) {
panic(errors.New("expected and observed files do not match"))
}
}
46 changes: 0 additions & 46 deletions main_test.go

This file was deleted.

4 changes: 2 additions & 2 deletions testdata/.vale.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
StylesPath = styles

Packages = ../Hugo.zip
Packages = ../MDX.zip

[*.md]
[*.mdx]
BasedOnStyles = Vale
56 changes: 56 additions & 0 deletions testdata/in.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Hello, world!

`import {External} from './some/place.js'`
`import {Chart} from './chart.js'`
`import population from './population.js'`

`export const pi = 3.14`
`export const Local = properties => <span style={{color: 'red'}} {...properties} />`

`<Chart data={population} label={'Something with ' + pi} />`

An `<External>external</External>` component and a `<Local>local one</Local>`.

<div className="note">
> Some notable things in a block quote!
</div>
`<Welcome name="Venus" />`
`<Welcome name="Mars" />`

`<MyComponent id="123" />`

You can also use objects with components, such as the `thisOne` component on
the `myComponents` object: `<myComponents.thisOne />`


```
<Component
open
x={1}
label={'this is a string, *not* markdown!'}
icon={`<Icon />`}
/>
```


Two 🍰 is: {Math.PI * 2}


```
{(function () {
const guess = Math.random()
if (guess > 0.66) {
return <span style={{color: 'tomato'}}>Look at us.</span>
}
if (guess > 0.33) {
return <span style={{color: 'violet'}}>Who would have guessed?!</span>
}
return <span style={{color: 'goldenrod'}}>Not me.</span>
})()}
```


81 changes: 0 additions & 81 deletions testdata/shortcodes.md

This file was deleted.

22 changes: 0 additions & 22 deletions testdata/test.ct

This file was deleted.

Loading

0 comments on commit 95d9474

Please sign in to comment.