Skip to content

Commit 3076bab

Browse files
committed
Update readme
1 parent a24c9bc commit 3076bab

File tree

2 files changed

+37
-10
lines changed

2 files changed

+37
-10
lines changed

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
# Modern Fortran language support for VSCode
22

3-
This extension provides support for the Fortran programming language. It includes syntax highlighting, code snippets and
4-
a linting based on gfortran.
5-
In the future will include autocompletion and documentation support...
3+
This extension provides support for the Fortran programming language. It includes syntax highlighting, code snippets and a linting based on gfortran.
4+
65
## Features
7-
vsce publish minor
6+
87
* Syntax highlighting
98
* Code Snippets
9+
* Documentation on hover for intrisic functions
1010
* Code linting based on `gfortran` to show errors swiggles in your code
1111

1212
## Requirements
13-
1413
For the linter to work you need to have `gfortran` on your path, or wherever you configure it to be.
15-
16-
14+
## Issues
15+
Please report any issues and feature request on the github repo [here](https://github.com/krvajalmiguelangel/vscode-fortran-support/issues/new)
1716
## Notice
1817
The syntax highlight support was imported from [TextMate bundle](https://github.com/textmate/fortran.tmbundle)
1918

src/features/hover-provider.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,38 @@ export default class FortranHoverProvider {
2929
let hover = new Hover(this.loadDocumentation(intrinsics[pos]));
3030
return hover;
3131
}
32-
private loadDocumentation(intrinsic: string):string{
33-
32+
private loadDocumentation(intrinsic: string):vscode.MarkedString {
3433
let docStringBuffer = fs.readFileSync(__dirname + "/../../../src/docs/" + intrinsic + ".html")
35-
return docStringBuffer.toString();
34+
let docText = docStringBuffer.toString();
35+
const codeRegex = /<code>(.+?)<\/code>\n?/g ;
36+
const varRegex = /<var>(.+?)<\/var>/g;
37+
const spanRegex = /<samp><span class="command">(\w+)<\/span><\/samp>/g;
38+
const tableRegex = /<table\s*.*>([\s\w<>\/\W]+?)<\/table>/g;
39+
const codeExampleRegex = /<code class="smallexample"[\s\W\w]*?>([\s\W\w<>]*?)<\/code>/g;
40+
const headerRegex = /^ *<h(\d)>(.+?)<\/h\1>\n?/gm;
41+
const defListRegex = /<dt>([\w\W]+?)<\/dt><dd>([\w\W]+?)(<br>)?<\/dd>/g;
42+
43+
docText = docText.replace(varRegex, (match, code:string) => {
44+
return "`" + code + "`";
45+
}).replace(spanRegex, (match,code) => `*${code}*`)
46+
.replace(defListRegex, (match,entry, def) => `**${entry}** ${def}\n`)
47+
.replace(codeExampleRegex, (match,code) => "```\n" + code + "\n\n```\n")
48+
.replace(/<td\s*.*?>([\s\w<>\/\W]+?)<\/td>/g, (match, code) => " | " + code)
49+
.replace(/<tr\s*.*?>([\s\w<>\/\W]+?)<\/tr>/g, (match, code) => code + "\n")
50+
.replace(/<tbody\s*.*?>([\s\w<>\/\W]+?)<\/tbody>/g, (match, code) => code)
51+
.replace(tableRegex, (match, code) => code)
52+
.replace(codeRegex, (match, code:string) => {
53+
return "`" + code + "`";
54+
}).replace(/<p>\s*?/g, "\n" )
55+
.replace(/<\/p>\s*?/g, "\n" )
56+
.replace(headerRegex, (match, h:string,code:string) => {
57+
let headerLevel: number = parseInt(h);
58+
let header = '#'.repeat(headerLevel);
59+
return `${header} ${code}\n`;
60+
});
61+
docText = docText.replace(/^ *<br>\n?/gm, '\n').replace(/<\?dl>/g,"");
62+
console.log(docText);
63+
return docText;
3664
}
3765

3866

0 commit comments

Comments
 (0)