obby-parser 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +39 -0
- package/build/Release/addon.exp +0 -0
- package/build/Release/addon.iobj +0 -0
- package/build/Release/addon.ipdb +0 -0
- package/build/Release/addon.lib +0 -0
- package/build/Release/addon.node +0 -0
- package/build/Release/addon.pdb +0 -0
- package/build/Release/obj/addon/addon.node.recipe +11 -0
- package/build/Release/obj/addon/addon.tlog/CL.command.1.tlog +0 -0
- package/build/Release/obj/addon/addon.tlog/CL.read.1.tlog +0 -0
- package/build/Release/obj/addon/addon.tlog/CL.write.1.tlog +0 -0
- package/build/Release/obj/addon/addon.tlog/Cl.items.tlog +2 -0
- package/build/Release/obj/addon/addon.tlog/addon.lastbuildstate +2 -0
- package/build/Release/obj/addon/addon.tlog/link.command.1.tlog +0 -0
- package/build/Release/obj/addon/addon.tlog/link.read.1.tlog +0 -0
- package/build/Release/obj/addon/addon.tlog/link.secondary.1.tlog +5 -0
- package/build/Release/obj/addon/addon.tlog/link.write.1.tlog +0 -0
- package/build/Release/obj/addon/src/addon.obj +0 -0
- package/build/Release/obj/addon/win_delay_load_hook.obj +0 -0
- package/build/addon.vcxproj +148 -0
- package/build/addon.vcxproj.filters +52 -0
- package/build/binding.sln +19 -0
- package/dist/example.d.ts +1 -0
- package/dist/example.js +18 -0
- package/dist/example.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/example.md +163 -0
- package/package.json +38 -0
- package/src/example.ts +13 -0
- package/src/index.ts +51 -0
- package/test/parser.spec.ts +25 -0
- package/test.html +1 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +18 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Caden McArthur
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Obsi-Parser
|
|
2
|
+
A helper package for converting markdown into html.
|
|
3
|
+
|
|
4
|
+
Supports obsidian style links and returns translated html and links to then be used on something like my personal website
|
|
5
|
+
|
|
6
|
+
# c-addon-example
|
|
7
|
+
|
|
8
|
+
Minimal example npm package showing how to call C code from Node using an N-API native addon.
|
|
9
|
+
|
|
10
|
+
## Requirements
|
|
11
|
+
- Node.js (LTS recommended)
|
|
12
|
+
- Python 3
|
|
13
|
+
- Native build tools (gcc/clang/Xcode/Visual Studio Build Tools)
|
|
14
|
+
|
|
15
|
+
## Build
|
|
16
|
+
Install dependencies and build the addon:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install
|
|
20
|
+
# (node-gyp runs via the install script and builds the addon)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or explicitly:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm run build
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
const { add } = require('c-addon-example');
|
|
33
|
+
console.log(add(2, 3)); // 5
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Notes
|
|
37
|
+
- To link an external C library, add the library to the repo or system and update `binding.gyp` with include_dirs and libraries entries.
|
|
38
|
+
- To publish prebuilt binaries for many platforms, use tools like `prebuild` or `prebuildify` and CI to build artifacts.
|
|
39
|
+
- For an alternative that avoids native compilation on user machines, consider compiling the C to WebAssembly or using `ffi-napi` to call precompiled shared libraries.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project>
|
|
3
|
+
<ProjectOutputs>
|
|
4
|
+
<ProjectOutput>
|
|
5
|
+
<FullPath>C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser\build\Release\addon.node</FullPath>
|
|
6
|
+
</ProjectOutput>
|
|
7
|
+
</ProjectOutputs>
|
|
8
|
+
<ContentFiles />
|
|
9
|
+
<SatelliteDlls />
|
|
10
|
+
<NonRecipeFileRefs />
|
|
11
|
+
</Project>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser\src\addon.c;C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser\build\Release\obj\addon\src\addon.obj
|
|
2
|
+
C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser\node_modules\node-gyp\src\win_delay_load_hook.cc;C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser\build\Release\obj\addon\win_delay_load_hook.obj
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
^C:\USERS\OUSOO\DESKTOP\PERSONALPROJECTS\OBSI-PARSER\BUILD\RELEASE\OBJ\ADDON\SRC\ADDON.OBJ|C:\USERS\OUSOO\DESKTOP\PERSONALPROJECTS\OBSI-PARSER\BUILD\RELEASE\OBJ\ADDON\WIN_DELAY_LOAD_HOOK.OBJ
|
|
2
|
+
C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser\build\Release\addon.LIB
|
|
3
|
+
C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser\build\Release\addon.EXP
|
|
4
|
+
C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser\build\Release\addon.IPDB
|
|
5
|
+
C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser\build\Release\addon.IOBJ
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<ItemGroup Label="ProjectConfigurations">
|
|
4
|
+
<ProjectConfiguration Include="Debug|x64">
|
|
5
|
+
<Configuration>Debug</Configuration>
|
|
6
|
+
<Platform>x64</Platform>
|
|
7
|
+
</ProjectConfiguration>
|
|
8
|
+
<ProjectConfiguration Include="Release|x64">
|
|
9
|
+
<Configuration>Release</Configuration>
|
|
10
|
+
<Platform>x64</Platform>
|
|
11
|
+
</ProjectConfiguration>
|
|
12
|
+
</ItemGroup>
|
|
13
|
+
<PropertyGroup Label="Globals">
|
|
14
|
+
<ProjectGuid>{169C297E-80DA-2C56-C6FE-BC6EC4152522}</ProjectGuid>
|
|
15
|
+
<Keyword>Win32Proj</Keyword>
|
|
16
|
+
<RootNamespace>addon</RootNamespace>
|
|
17
|
+
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
|
|
18
|
+
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
|
|
19
|
+
<WindowsTargetPlatformVersion>10.0.26100.0</WindowsTargetPlatformVersion>
|
|
20
|
+
</PropertyGroup>
|
|
21
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
|
|
22
|
+
<PropertyGroup Label="Configuration">
|
|
23
|
+
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
24
|
+
</PropertyGroup>
|
|
25
|
+
<PropertyGroup Label="Locals">
|
|
26
|
+
<PlatformToolset>v143</PlatformToolset>
|
|
27
|
+
</PropertyGroup>
|
|
28
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
|
|
29
|
+
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props"/>
|
|
30
|
+
<ImportGroup Label="ExtensionSettings"/>
|
|
31
|
+
<ImportGroup Label="PropertySheets">
|
|
32
|
+
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
|
33
|
+
</ImportGroup>
|
|
34
|
+
<PropertyGroup Label="UserMacros"/>
|
|
35
|
+
<PropertyGroup>
|
|
36
|
+
<ExecutablePath>$(ExecutablePath);$(MSBuildProjectDirectory)\..\bin\;$(MSBuildProjectDirectory)\..\bin\</ExecutablePath>
|
|
37
|
+
<IgnoreImportLibrary>true</IgnoreImportLibrary>
|
|
38
|
+
<IntDir>$(Configuration)\obj\$(ProjectName)\</IntDir>
|
|
39
|
+
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
|
|
40
|
+
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
|
|
41
|
+
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
|
|
42
|
+
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.node</TargetExt>
|
|
43
|
+
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.node</TargetExt>
|
|
44
|
+
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.node</TargetExt>
|
|
45
|
+
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.node</TargetExt>
|
|
46
|
+
<TargetName>$(ProjectName)</TargetName>
|
|
47
|
+
<TargetPath>$(OutDir)\$(ProjectName).node</TargetPath>
|
|
48
|
+
</PropertyGroup>
|
|
49
|
+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
50
|
+
<ClCompile>
|
|
51
|
+
<AdditionalIncludeDirectories>C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\include\node;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\src;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\openssl\config;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\openssl\openssl\include;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\uv\include;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\zlib;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\v8\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
52
|
+
<AdditionalOptions>/Zc:__cplusplus -std:c++20 /Zm2000 %(AdditionalOptions)</AdditionalOptions>
|
|
53
|
+
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
|
54
|
+
<BufferSecurityCheck>true</BufferSecurityCheck>
|
|
55
|
+
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
|
56
|
+
<DisableSpecificWarnings>4351;4355;4800;4251;4275;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
57
|
+
<ExceptionHandling>false</ExceptionHandling>
|
|
58
|
+
<MinimalRebuild>false</MinimalRebuild>
|
|
59
|
+
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
60
|
+
<OmitFramePointers>false</OmitFramePointers>
|
|
61
|
+
<Optimization>Disabled</Optimization>
|
|
62
|
+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
63
|
+
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=addon;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
64
|
+
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
65
|
+
<StringPooling>true</StringPooling>
|
|
66
|
+
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
67
|
+
<TreatWarningAsError>false</TreatWarningAsError>
|
|
68
|
+
<WarningLevel>Level3</WarningLevel>
|
|
69
|
+
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
70
|
+
</ClCompile>
|
|
71
|
+
<Lib>
|
|
72
|
+
<AdditionalOptions>/LTCG:INCREMENTAL %(AdditionalOptions)</AdditionalOptions>
|
|
73
|
+
</Lib>
|
|
74
|
+
<Link>
|
|
75
|
+
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;delayimp.lib;"C:\\Users\\ousoo\\AppData\\Local\\node-gyp\\Cache\\22.20.0\\x64\\node.lib"</AdditionalDependencies>
|
|
76
|
+
<AdditionalOptions>/LTCG:INCREMENTAL /ignore:4199 %(AdditionalOptions)</AdditionalOptions>
|
|
77
|
+
<DelayLoadDLLs>node.exe;%(DelayLoadDLLs)</DelayLoadDLLs>
|
|
78
|
+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
79
|
+
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
80
|
+
<OptimizeReferences>true</OptimizeReferences>
|
|
81
|
+
<OutputFile>$(OutDir)$(ProjectName).node</OutputFile>
|
|
82
|
+
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
83
|
+
<TargetExt>.node</TargetExt>
|
|
84
|
+
<TargetMachine>MachineX64</TargetMachine>
|
|
85
|
+
</Link>
|
|
86
|
+
<ResourceCompile>
|
|
87
|
+
<AdditionalIncludeDirectories>C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\include\node;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\src;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\openssl\config;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\openssl\openssl\include;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\uv\include;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\zlib;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\v8\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
88
|
+
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=addon;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";DEBUG;_DEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
89
|
+
</ResourceCompile>
|
|
90
|
+
</ItemDefinitionGroup>
|
|
91
|
+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
92
|
+
<ClCompile>
|
|
93
|
+
<AdditionalIncludeDirectories>C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\include\node;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\src;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\openssl\config;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\openssl\openssl\include;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\uv\include;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\zlib;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\v8\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
94
|
+
<AdditionalOptions>/Zc:__cplusplus -std:c++20 /Zm2000 %(AdditionalOptions)</AdditionalOptions>
|
|
95
|
+
<BufferSecurityCheck>true</BufferSecurityCheck>
|
|
96
|
+
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
|
97
|
+
<DisableSpecificWarnings>4351;4355;4800;4251;4275;4244;4267;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
|
98
|
+
<ExceptionHandling>false</ExceptionHandling>
|
|
99
|
+
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
|
100
|
+
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
101
|
+
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
|
102
|
+
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
103
|
+
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
104
|
+
<OmitFramePointers>true</OmitFramePointers>
|
|
105
|
+
<Optimization>Full</Optimization>
|
|
106
|
+
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
|
107
|
+
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=addon;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
108
|
+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
109
|
+
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
|
110
|
+
<StringPooling>true</StringPooling>
|
|
111
|
+
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
112
|
+
<TreatWarningAsError>false</TreatWarningAsError>
|
|
113
|
+
<WarningLevel>Level3</WarningLevel>
|
|
114
|
+
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
115
|
+
</ClCompile>
|
|
116
|
+
<Lib>
|
|
117
|
+
<AdditionalOptions>/LTCG:INCREMENTAL %(AdditionalOptions)</AdditionalOptions>
|
|
118
|
+
</Lib>
|
|
119
|
+
<Link>
|
|
120
|
+
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;delayimp.lib;"C:\\Users\\ousoo\\AppData\\Local\\node-gyp\\Cache\\22.20.0\\x64\\node.lib"</AdditionalDependencies>
|
|
121
|
+
<AdditionalOptions>/LTCG:INCREMENTAL /ignore:4199 %(AdditionalOptions)</AdditionalOptions>
|
|
122
|
+
<DelayLoadDLLs>node.exe;%(DelayLoadDLLs)</DelayLoadDLLs>
|
|
123
|
+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
124
|
+
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
125
|
+
<OptimizeReferences>true</OptimizeReferences>
|
|
126
|
+
<OutputFile>$(OutDir)$(ProjectName).node</OutputFile>
|
|
127
|
+
<SuppressStartupBanner>true</SuppressStartupBanner>
|
|
128
|
+
<TargetExt>.node</TargetExt>
|
|
129
|
+
<TargetMachine>MachineX64</TargetMachine>
|
|
130
|
+
</Link>
|
|
131
|
+
<ResourceCompile>
|
|
132
|
+
<AdditionalIncludeDirectories>C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\include\node;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\src;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\openssl\config;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\openssl\openssl\include;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\uv\include;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\zlib;C:\Users\ousoo\AppData\Local\node-gyp\Cache\22.20.0\deps\v8\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
133
|
+
<PreprocessorDefinitions>NODE_GYP_MODULE_NAME=addon;USING_UV_SHARED=1;USING_V8_SHARED=1;V8_DEPRECATION_WARNINGS=1;_GLIBCXX_USE_CXX11_ABI=1;_FILE_OFFSET_BITS=64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;NOMINMAX;OPENSSL_NO_PINSHARED;OPENSSL_THREADS;BUILDING_NODE_EXTENSION;HOST_BINARY="node.exe";%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
134
|
+
</ResourceCompile>
|
|
135
|
+
</ItemDefinitionGroup>
|
|
136
|
+
<ItemGroup>
|
|
137
|
+
<None Include="..\binding.gyp"/>
|
|
138
|
+
</ItemGroup>
|
|
139
|
+
<ItemGroup>
|
|
140
|
+
<ClCompile Include="..\src\addon.c">
|
|
141
|
+
<ObjectFileName>$(IntDir)\src\addon.obj</ObjectFileName>
|
|
142
|
+
</ClCompile>
|
|
143
|
+
<ClCompile Include="C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser\node_modules\node-gyp\src\win_delay_load_hook.cc"/>
|
|
144
|
+
</ItemGroup>
|
|
145
|
+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
|
|
146
|
+
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets"/>
|
|
147
|
+
<ImportGroup Label="ExtensionTargets"/>
|
|
148
|
+
</Project>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
+
<ItemGroup>
|
|
4
|
+
<Filter Include="..">
|
|
5
|
+
<UniqueIdentifier>{739DB09A-CC57-A953-A6CF-F64FA08E4FA7}</UniqueIdentifier>
|
|
6
|
+
</Filter>
|
|
7
|
+
<Filter Include="..\src">
|
|
8
|
+
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
|
|
9
|
+
</Filter>
|
|
10
|
+
<Filter Include="C:">
|
|
11
|
+
<UniqueIdentifier>{7B735499-E5DD-1C2B-6C26-70023832A1CF}</UniqueIdentifier>
|
|
12
|
+
</Filter>
|
|
13
|
+
<Filter Include="C:\Users">
|
|
14
|
+
<UniqueIdentifier>{E9F714C1-DA89-54E2-60CF-39FEB20BF756}</UniqueIdentifier>
|
|
15
|
+
</Filter>
|
|
16
|
+
<Filter Include="C:\Users\ousoo">
|
|
17
|
+
<UniqueIdentifier>{BD0AFDDD-FFDA-2EF4-3616-3CE6B8C29230}</UniqueIdentifier>
|
|
18
|
+
</Filter>
|
|
19
|
+
<Filter Include="C:\Users\ousoo\Desktop">
|
|
20
|
+
<UniqueIdentifier>{B23D6E4D-7634-EF57-62FC-46A6189C0B6E}</UniqueIdentifier>
|
|
21
|
+
</Filter>
|
|
22
|
+
<Filter Include="C:\Users\ousoo\Desktop\personalProjects">
|
|
23
|
+
<UniqueIdentifier>{3FE31B32-61D7-60DD-3D12-8276333F2D94}</UniqueIdentifier>
|
|
24
|
+
</Filter>
|
|
25
|
+
<Filter Include="C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser">
|
|
26
|
+
<UniqueIdentifier>{3986AA5F-6C76-AA49-412E-818DCD9809A1}</UniqueIdentifier>
|
|
27
|
+
</Filter>
|
|
28
|
+
<Filter Include="C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser\node_modules">
|
|
29
|
+
<UniqueIdentifier>{56DF7A98-063D-FB9D-485C-089023B4C16A}</UniqueIdentifier>
|
|
30
|
+
</Filter>
|
|
31
|
+
<Filter Include="C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser\node_modules\node-gyp">
|
|
32
|
+
<UniqueIdentifier>{77348C0E-2034-7791-74D5-63C077DF5A3B}</UniqueIdentifier>
|
|
33
|
+
</Filter>
|
|
34
|
+
<Filter Include="C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser\node_modules\node-gyp\src">
|
|
35
|
+
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
|
|
36
|
+
</Filter>
|
|
37
|
+
<Filter Include="..">
|
|
38
|
+
<UniqueIdentifier>{739DB09A-CC57-A953-A6CF-F64FA08E4FA7}</UniqueIdentifier>
|
|
39
|
+
</Filter>
|
|
40
|
+
</ItemGroup>
|
|
41
|
+
<ItemGroup>
|
|
42
|
+
<ClCompile Include="..\src\addon.c">
|
|
43
|
+
<Filter>..\src</Filter>
|
|
44
|
+
</ClCompile>
|
|
45
|
+
<ClCompile Include="C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser\node_modules\node-gyp\src\win_delay_load_hook.cc">
|
|
46
|
+
<Filter>C:\Users\ousoo\Desktop\personalProjects\Obsi-Parser\node_modules\node-gyp\src</Filter>
|
|
47
|
+
</ClCompile>
|
|
48
|
+
<None Include="..\binding.gyp">
|
|
49
|
+
<Filter>..</Filter>
|
|
50
|
+
</None>
|
|
51
|
+
</ItemGroup>
|
|
52
|
+
</Project>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
2
|
+
# Visual Studio 2015
|
|
3
|
+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "addon", "addon.vcxproj", "{169C297E-80DA-2C56-C6FE-BC6EC4152522}"
|
|
4
|
+
EndProject
|
|
5
|
+
Global
|
|
6
|
+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
7
|
+
Debug|x64 = Debug|x64
|
|
8
|
+
Release|x64 = Release|x64
|
|
9
|
+
EndGlobalSection
|
|
10
|
+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
11
|
+
{169C297E-80DA-2C56-C6FE-BC6EC4152522}.Debug|x64.ActiveCfg = Debug|x64
|
|
12
|
+
{169C297E-80DA-2C56-C6FE-BC6EC4152522}.Debug|x64.Build.0 = Debug|x64
|
|
13
|
+
{169C297E-80DA-2C56-C6FE-BC6EC4152522}.Release|x64.ActiveCfg = Release|x64
|
|
14
|
+
{169C297E-80DA-2C56-C6FE-BC6EC4152522}.Release|x64.Build.0 = Release|x64
|
|
15
|
+
EndGlobalSection
|
|
16
|
+
GlobalSection(SolutionProperties) = preSolution
|
|
17
|
+
HideSolutionNode = FALSE
|
|
18
|
+
EndGlobalSection
|
|
19
|
+
EndGlobal
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/example.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = __importDefault(require("fs"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const index_1 = require("./index");
|
|
9
|
+
const input = process.argv[2] || path_1.default.join(process.cwd(), "example.md");
|
|
10
|
+
if (!fs_1.default.existsSync(input)) {
|
|
11
|
+
console.error("No input file found:", input);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const content = fs_1.default.readFileSync(input, "utf8");
|
|
15
|
+
const result = (0, index_1.parseMarkdown)(content, "www.personalwebsite.com/test/");
|
|
16
|
+
console.log("HTML output:\n", result.html);
|
|
17
|
+
console.log("\nLinks found:", result.links_set);
|
|
18
|
+
//# sourceMappingURL=example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.js","sourceRoot":"","sources":["../src/example.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,mCAAwC;AAExC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;AACxE,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;IAC1B,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;IAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AACD,MAAM,OAAO,GAAG,YAAE,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC/C,MAAM,MAAM,GAAG,IAAA,qBAAa,EAAC,OAAO,EAAE,+BAA+B,CAAC,CAAC;AACvE,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;AAC3C,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* parseMarkdown
|
|
3
|
+
* - Accepts an Obsidian-style markdown string.
|
|
4
|
+
* - Finds all [[wikilinks]] and collects them into links[].
|
|
5
|
+
* - Replaces [[Name]] with an <a href="Name.html">Name</a> (simple default transform).
|
|
6
|
+
* - Returns the HTML (via markdown-it) and the array of links found.
|
|
7
|
+
* - This is a one way operation meant to just translate markdown files for the web
|
|
8
|
+
*/
|
|
9
|
+
export type ParseResult = {
|
|
10
|
+
html: string;
|
|
11
|
+
links_set: Set<string>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Main exported function.
|
|
15
|
+
* route should be setup in a way for you to handle params easily
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseMarkdown(markdown: string, route: string): ParseResult;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* parseMarkdown
|
|
4
|
+
* - Accepts an Obsidian-style markdown string.
|
|
5
|
+
* - Finds all [[wikilinks]] and collects them into links[].
|
|
6
|
+
* - Replaces [[Name]] with an <a href="Name.html">Name</a> (simple default transform).
|
|
7
|
+
* - Returns the HTML (via markdown-it) and the array of links found.
|
|
8
|
+
* - This is a one way operation meant to just translate markdown files for the web
|
|
9
|
+
*/
|
|
10
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.parseMarkdown = parseMarkdown;
|
|
15
|
+
const markdown_it_1 = __importDefault(require("markdown-it"));
|
|
16
|
+
const md = new markdown_it_1.default();
|
|
17
|
+
/**
|
|
18
|
+
* Normalize link text to a safe file name or slug.
|
|
19
|
+
* For now, this is minimal: trim and replace spaces with dashes.
|
|
20
|
+
*/
|
|
21
|
+
function normalizeLinkText(text) {
|
|
22
|
+
return text.trim().replace(/\s+/g, "-");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Replace [[link]] occurrences with a placeholder anchor and collect links.
|
|
26
|
+
*/
|
|
27
|
+
function transformWikilinks(input, route, links) {
|
|
28
|
+
// Use a replacer so we can capture multiple occurrences
|
|
29
|
+
return input.replace(/\[\[([^\]]+)\]\]/g, (_, inner) => {
|
|
30
|
+
const display = inner.trim();
|
|
31
|
+
const href = ` ${route}${normalizeLinkText(display)}`;
|
|
32
|
+
links.add(display);
|
|
33
|
+
// Return markdown inline HTML anchor; markdown-it will preserve it
|
|
34
|
+
return `<a href="${href}" target="_blank" rel="noopener noreferrer">${display}</a>`;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Main exported function.
|
|
39
|
+
* route should be setup in a way for you to handle params easily
|
|
40
|
+
*/
|
|
41
|
+
function parseMarkdown(markdown, route) {
|
|
42
|
+
const links_set = new Set();
|
|
43
|
+
const withAnchors = transformWikilinks(markdown, route, links_set);
|
|
44
|
+
const html = md.render(withAnchors);
|
|
45
|
+
return { html, links_set };
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;AAsCH,sCAKC;AAzCD,8DAAqC;AAOrC,MAAM,EAAE,GAAG,IAAI,qBAAU,EAAE,CAAC;AAE5B;;;GAGG;AACH,SAAS,iBAAiB,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE1C,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,KAAa,EAAE,KAAa,EAAE,KAAkB;IAC1E,wDAAwD;IACxD,OAAO,KAAK,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC,EAAE,KAAa,EAAE,EAAE;QAC7D,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,IAAI,KAAK,GAAG,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC;QACtD,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACnB,mEAAmE;QACnE,OAAO,YAAY,IAAI,+CAA+C,OAAO,MAAM,CAAC;IACtF,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,QAAgB,EAAE,KAAa;IAC3D,MAAM,SAAS,GAAgB,IAAI,GAAG,EAAE,CAAC;IACzC,MAAM,WAAW,GAAG,kBAAkB,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IACnE,MAAM,IAAI,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACpC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC7B,CAAC"}
|
package/example.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
|
|
2
|
+
2024-08-26 08:39
|
|
3
|
+
|
|
4
|
+
Status:
|
|
5
|
+
|
|
6
|
+
Tags:[[C Book]], [[C]], [[Programming Language]]
|
|
7
|
+
|
|
8
|
+
# C Book Ch 1
|
|
9
|
+
The [[C]] [[Programming Language]] is a general purpose programming language.
|
|
10
|
+
|
|
11
|
+
[[C]] is not a very high level language nor a big one and is not specilized to any particular area of application.
|
|
12
|
+
|
|
13
|
+
[[C]] was designed for and implemented into [[UNIX]] operating systems. Essentially all [[UNIX]] application programs are written in [[C]]
|
|
14
|
+
|
|
15
|
+
A [[C]] program no matter its size consists of [[Functions]] and [[Variables]].
|
|
16
|
+
|
|
17
|
+
#include <stdio.h> tells the compilier to include information about the standard input/output [[C Libraries]], this line will begin most files.
|
|
18
|
+
|
|
19
|
+
in this example
|
|
20
|
+
|
|
21
|
+
main(){
|
|
22
|
+
printf("hello world\n")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
main is defined to be a function that expects no arugments
|
|
26
|
+
\n is a newline character
|
|
27
|
+
|
|
28
|
+
# 1.2 Variables and Arithmetic Expressions
|
|
29
|
+
|
|
30
|
+
#include <stdio.h>
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
int main(){
|
|
35
|
+
int fahr, celcius;
|
|
36
|
+
int lower, upper, step;
|
|
37
|
+
lower = 0; /*lower limit of the temp table*/
|
|
38
|
+
upper = 300; /*upper limit of the temp table*/
|
|
39
|
+
step = 20; /*step size*/
|
|
40
|
+
fahr = lower;
|
|
41
|
+
while(fahr <= upper){
|
|
42
|
+
celcius = 5 * (fahr-32) / 9;
|
|
43
|
+
printf("%d\t%d\n", fahr, celcius);
|
|
44
|
+
fahr = fahr + step;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
Comments are defined in [[C]] as /*
|
|
49
|
+
|
|
50
|
+
in [[C]] all [[Variables]] must be declared before they are used, a declaration announces the properties of variables; it consists of a type name and a list of variables
|
|
51
|
+
|
|
52
|
+
[[While loop]] was used in this as well
|
|
53
|
+
|
|
54
|
+
The reason for multiplying by 5 and then dividing by 9 instead of just multiplying by 5/9 is that in [[C]], integer division truncates: any fractional part is discarded. Since 5 and 9 are integers, 5/9 would be truncated to 0.
|
|
55
|
+
|
|
56
|
+
1.3 The [[For statement loop]]
|
|
57
|
+
|
|
58
|
+
int main(){
|
|
59
|
+
int fahr;
|
|
60
|
+
for (fahr = 0; fahr <= 300; fahr + 20){
|
|
61
|
+
printf("%3d %6.1f\n", fahr, (5.0/9.0) * (fahr-32))
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
This program gets us the same answer with fewer variables
|
|
65
|
+
|
|
66
|
+
# 1.4 Symbolic constants
|
|
67
|
+
[[Symbolic Constants]] - more definition
|
|
68
|
+
It's bad practice to bury "magic numbers" like 300 and 20 into the program; they convey little information to someone who might read the program later
|
|
69
|
+
(# define) line defines a symbolic name or symbolic constant to be a particular string of characters
|
|
70
|
+
(# define name replacement text)
|
|
71
|
+
|
|
72
|
+
Therefore after any occurrence of name will be replaced by the corresponding replacement text.
|
|
73
|
+
|
|
74
|
+
# 1.5 Character Input and Output
|
|
75
|
+
|
|
76
|
+
The model of input and output supported by the standard library is very simple. Text input or output, regardless of where it originates or where it goes to, is dealt with as streams of characters.
|
|
77
|
+
|
|
78
|
+
A Text Stream is a sequence of characters divided into lines each line consists of zero or more characters followed by a newline character.
|
|
79
|
+
|
|
80
|
+
It is the responsibility of the library to make each stream conform to this model.
|
|
81
|
+
|
|
82
|
+
The standard library provides functions for reading or writing one character at a time, of which [[getchar]] and [[putchar]] are the simplest.
|
|
83
|
+
|
|
84
|
+
# 1.5.1 file copying
|
|
85
|
+
|
|
86
|
+
Now that we know [[getchar]] and [[putchar]] lots of useful code can be made
|
|
87
|
+
|
|
88
|
+
read a character
|
|
89
|
+
while(character is not end-of-file indicator)
|
|
90
|
+
output the character just read
|
|
91
|
+
read a character
|
|
92
|
+
(#)include <stdio.h>
|
|
93
|
+
|
|
94
|
+
int main(){
|
|
95
|
+
int c;
|
|
96
|
+
c = getchar();
|
|
97
|
+
while (c != EOF){
|
|
98
|
+
putchar(c);
|
|
99
|
+
c = getchar();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
# 1.5.2 Character counting
|
|
104
|
+
|
|
105
|
+
#include <stdio.h>
|
|
106
|
+
|
|
107
|
+
int main(){
|
|
108
|
+
|
|
109
|
+
long count;
|
|
110
|
+
count = 0;
|
|
111
|
+
|
|
112
|
+
while(getchar() != EOF){
|
|
113
|
+
|
|
114
|
+
++count;
|
|
115
|
+
|
|
116
|
+
printf("%d\n", count);
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
the ++ operator increments by 1, the -- decrements. They can either be a prefix or a suffix, sometimes prefix/postfix have different meanings
|
|
123
|
+
|
|
124
|
+
# word counting plus line counting plus character counting
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
#include <stdio.h>
|
|
130
|
+
|
|
131
|
+
#define IN 1
|
|
132
|
+
|
|
133
|
+
#define OUT 0 /*inside or outside a word*/
|
|
134
|
+
|
|
135
|
+
int main(){
|
|
136
|
+
int cha, nl, nw, nc, state;
|
|
137
|
+
state = OUT;
|
|
138
|
+
nl = nw = nc = 0;
|
|
139
|
+
while((cha = getchar()) != EOF){
|
|
140
|
+
++nc;
|
|
141
|
+
if (cha == '\n'){
|
|
142
|
+
++nl;
|
|
143
|
+
};
|
|
144
|
+
if (cha == ' ' || cha == '\n' || cha == '\t'){
|
|
145
|
+
state = OUT;
|
|
146
|
+
}
|
|
147
|
+
else if(state == OUT){
|
|
148
|
+
state = IN;
|
|
149
|
+
++nw;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
printf("%d %d %d\n", nl, nw, nc);
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
# 1.6 Arrays
|
|
158
|
+
|
|
159
|
+
To continue building off of the previous character count program
|
|
160
|
+
|
|
161
|
+
lets count the number of occurrences of each digit, of whitespace characters, and all other characters.
|
|
162
|
+
|
|
163
|
+
There are 12 categories of input possible, so it is convenient to use an array to hold the number of occurrences of each digit, rather than ten individual variables
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "obby-parser",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Parse Obsidian-style markdown files including ([[links]]) into HTML and extract links",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"clean": "rimraf dist",
|
|
9
|
+
"build": "tsc -p tsconfig.build.json",
|
|
10
|
+
"dev": "ts-node src/example.ts",
|
|
11
|
+
"test": "vitest",
|
|
12
|
+
"lint": "eslint \"src/**/*.ts\"",
|
|
13
|
+
"prepare": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"obsidian",
|
|
17
|
+
"markdown",
|
|
18
|
+
"parser",
|
|
19
|
+
"npx",
|
|
20
|
+
"typescript"
|
|
21
|
+
],
|
|
22
|
+
"author": "cmac2112",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"markdown-it": "^13.0.2"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/markdown-it": "^14.1.2",
|
|
29
|
+
"@types/node": "^20.0.0",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
31
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
32
|
+
"eslint": "^8.0.0",
|
|
33
|
+
"rimraf": "^5.0.0",
|
|
34
|
+
"ts-node": "^10.9.1",
|
|
35
|
+
"typescript": "^5.0.0",
|
|
36
|
+
"vitest": "^1.4.0"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/example.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { parseMarkdown } from "./index";
|
|
4
|
+
|
|
5
|
+
const input = process.argv[2] || path.join(process.cwd(), "example.md");
|
|
6
|
+
if (!fs.existsSync(input)) {
|
|
7
|
+
console.error("No input file found:", input);
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
const content = fs.readFileSync(input, "utf8");
|
|
11
|
+
const result = parseMarkdown(content, "www.personalwebsite.com/test/");
|
|
12
|
+
console.log("HTML output:\n", result.html);
|
|
13
|
+
console.log("\nLinks found:", result.links_set);
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* parseMarkdown
|
|
3
|
+
* - Accepts an Obsidian-style markdown string.
|
|
4
|
+
* - Finds all [[wikilinks]] and collects them into links[].
|
|
5
|
+
* - Replaces [[Name]] with an <a href="Name.html">Name</a> (simple default transform).
|
|
6
|
+
* - Returns the HTML (via markdown-it) and the array of links found.
|
|
7
|
+
* - This is a one way operation meant to just translate markdown files for the web
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import MarkdownIt from "markdown-it";
|
|
11
|
+
|
|
12
|
+
export type ParseResult = {
|
|
13
|
+
html: string;
|
|
14
|
+
links_set: Set<string>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const md = new MarkdownIt();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Normalize link text to a safe file name or slug.
|
|
21
|
+
* For now, this is minimal: trim and replace spaces with dashes.
|
|
22
|
+
*/
|
|
23
|
+
function normalizeLinkText(text: string): string {
|
|
24
|
+
return text.trim().replace(/\s+/g, "-");
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Replace [[link]] occurrences with a placeholder anchor and collect links.
|
|
30
|
+
*/
|
|
31
|
+
function transformWikilinks(input: string, route: string, links: Set<string>): string {
|
|
32
|
+
// Use a replacer so we can capture multiple occurrences
|
|
33
|
+
return input.replace(/\[\[([^\]]+)\]\]/g, (_, inner: string) => {
|
|
34
|
+
const display = inner.trim();
|
|
35
|
+
const href = ` ${route}${normalizeLinkText(display)}`;
|
|
36
|
+
links.add(display);
|
|
37
|
+
// Return markdown inline HTML anchor; markdown-it will preserve it
|
|
38
|
+
return `<a href="${href}" target="_blank" rel="noopener noreferrer">${display}</a>`;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Main exported function.
|
|
44
|
+
* route should be setup in a way for you to handle params easily
|
|
45
|
+
*/
|
|
46
|
+
export function parseMarkdown(markdown: string, route: string): ParseResult {
|
|
47
|
+
const links_set: Set<string> = new Set();
|
|
48
|
+
const withAnchors = transformWikilinks(markdown, route, links_set);
|
|
49
|
+
const html = md.render(withAnchors);
|
|
50
|
+
return { html, links_set };
|
|
51
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { parseMarkdown } from "../src/index";
|
|
3
|
+
|
|
4
|
+
let pageTest: Set<string> = new Set<string>();
|
|
5
|
+
let linkTest: Set<string> = new Set<string>();
|
|
6
|
+
describe("parseMarkdown", () => {
|
|
7
|
+
it("converts [[wikilink]] to an anchor and collects link", () => {
|
|
8
|
+
const input = "This references [[My Page]] and also inline **bold** text.";
|
|
9
|
+
const { html, links_set } = parseMarkdown(input, "test/");
|
|
10
|
+
pageTest.add("My Page")
|
|
11
|
+
|
|
12
|
+
expect(links_set).toEqual(pageTest);
|
|
13
|
+
expect(html).toContain('<a href=" test/My-Page" target="_blank" rel="noopener noreferrer">My Page</a>');
|
|
14
|
+
expect(html).toContain("<strong>bold</strong>");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("handles multiple wikilinks", () => {
|
|
18
|
+
const input = "[[One]] and [[Two]] and again [[One]]";
|
|
19
|
+
const { links_set } = parseMarkdown(input, "test/");
|
|
20
|
+
linkTest.add("One")
|
|
21
|
+
linkTest.add("Two")
|
|
22
|
+
expect(links_set).toEqual(linkTest);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
// more robust tests are needed
|
package/test.html
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<a href="https://www.personalwebsite.com/test/C-Book" target="_blank" rel="noopener noreferrer">C Book</a>
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"rootDir": "./src",
|
|
7
|
+
"moduleResolution": "Node",
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"sourceMap": true,
|
|
13
|
+
"baseUrl": ".",
|
|
14
|
+
"resolveJsonModule": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["src/index.ts"],
|
|
17
|
+
"exclude": ["node_modules", "dist","test"]
|
|
18
|
+
}
|