Skip to content
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

Fix the levenstein_distances stat reporting #39

Merged
merged 5 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ Output:
╭──────────────────────┬───────────────────────────────────╮
│ filename │ simple_markdown_with_no_output.md │
│ nushell_code_blocks │ 3 │
│ levenshtein_distance │ 40
│ diff_lines │ +6 (25%)
│ diff_words │ +7 (12.5%) │
│ diff_chars │ +40 (11.7%)
│ levenshtein_distance │ 38
│ diff_lines │ +9 (37.5%)
│ diff_words │ +6 (10.7%) │
│ diff_chars │ +38 (11%)
╰──────────────────────┴───────────────────────────────────╯
```

Expand Down Expand Up @@ -215,7 +215,7 @@ Input/output types:
╰─────────────────name──────────────────┴─type─╯

> sys host | get boot_time
Fri, 24 May 2024 07:47:13 +0000 (2 weeks ago)
Fri, 24 May 2024 07:47:14 +0000 (3 weeks ago)

> 2 + 2
4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ Output:
// ╭──────────────────────┬────────────────────╮
// │ filename │ simple_markdown.md │
// │ nushell_code_blocks │ 3 │
// │ levenshtein_distance │ 1
// │ levenshtein_distance │ 0
// │ diff_lines │ 0% │
// │ diff_words │ 0% │
// │ diff_chars │ +1 (0.3%)
// │ diff_chars │ 0%
// ╰──────────────────────┴────────────────────╯
```
4 changes: 2 additions & 2 deletions numd/nu-utils/numd-internals.nu
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ export def calc-changes [
orig_file: string
new_file: string
]: nothing -> record {
let $original_file_content = $orig_file | ansi strip
let $new_file_content = $new_file | ansi strip | replace-output-numd-fences
let $original_file_content = $orig_file | ansi strip | $in + "\n" # to fix https://github.com/nushell/nushell/issues/13155
let $new_file_content = $new_file | ansi strip

let $nushell_code_blocks = detect-code-blocks $new_file_content
| where row_type =~ '^```nu'
Expand Down
12 changes: 7 additions & 5 deletions numd/run1.nu
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ export def run [
--diff # use diff for printing changes
--width: int # set the `table --width` option value
]: [nothing -> nothing, nothing -> string, nothing -> record] {
let $original_md = open -r $file | replace-output-numd-fences
let $original_md = open -r $file

let $original_md_table = detect-code-blocks $original_md
let $original_md_table = $original_md
| replace-output-numd-fences
| detect-code-blocks $in

if $width != null {
$env.numd.table-width = $width
Expand Down Expand Up @@ -88,9 +90,9 @@ export def clear-outputs [
--echo # output resulting markdown to the terminal instead of writing to file
--strip-markdown # keep only Nushell script, strip all markdown tags
]: [nothing -> nothing, nothing -> string, nothing -> record] {
let $original_md = open -r $file | replace-output-numd-fences

let $original_md_table = detect-code-blocks $original_md
let $original_md_table = open -r $file
| replace-output-numd-fences
| detect-code-blocks $in

let $output_md_path = $output_md_path | default $file

Expand Down