Commit Graph

39 Commits

Author SHA1 Message Date
Dylan Lom 1fbd578186
Merge pull request #9 from dylan-lom/#5-header-wrapped-in-p-tag
(#5) Extra to remove <p> tags around <head>
2021-02-06 18:13:30 +11:00
Dylan Lom 0e827d0fad (#5) Add shmd-good-html script 2021-02-06 18:11:57 +11:00
Dylan Lom cdcc977f59 (#5) Add script to remove p tags around head 2021-02-06 18:02:21 +11:00
Dylan Lom affe6e2e4d Wrap header in <head> tags properly
* In re-writing that logic I broke this (oops!)
2021-02-06 17:57:41 +11:00
Dylan Lom 87d5c9087a
Merge pull request #8 from dylan-lom/#4
(#4) Implement header functions
2021-02-06 17:49:52 +11:00
Dylan Lom b45047a3bc Merge branch 'master' into #4 2021-02-06 17:49:26 +11:00
Dylan Lom c7d1b0b97a Remove unused variable
Reformat tmp-free pattern in header_process so it's the same as the rest
of the codebase.
2021-02-06 17:45:55 +11:00
Dylan Lom cc017a28bf (#6) Re-implement header and functions better 2021-02-06 17:38:57 +11:00
Dylan Lom 8fbbc8e192 (#6) Start refactoring header logic
REGRESSION: Headers and functions are currently in a BROKEN state, but
at least the code base is a little nicer right? :)
2021-02-06 16:43:38 +11:00
Dylan Lom 14910e7967 Merge 'master' into #4
Squashed commit of the following:

commit 74b0e7aa54
Author: Dylan Lom <dylanlom@gmail.com>
Date:   Tue Jan 26 13:01:39 2021 +1100

    Fix bug with link elements

    Link tags in the header were using "vals=" instead of "href="...
2021-02-04 19:21:38 +11:00
Dylan Lom f9d07ac21a Format util.h
* Formalise usage function with argument type void.
2021-01-26 19:31:00 +11:00
Dylan Lom 9f4ac595a8 (#4) Ignore nested quotes in header
If there is an opening quotation (ie. `'`), internal quotes (ie. `"`)
will be preserved. This allows for cleaner function declarations.
2021-01-26 18:40:27 +11:00
Dylan Lom 1a7fb05cdb (#4) Implement header functions
* Need to backslash *any* quotes in function bodys. Should change how
  quoting works so that any quotes within an outer quote are preserved.
2021-01-26 18:36:35 +11:00
Dylan Lom e46eb73468 (#4) Make header properties available as variables 2021-01-26 18:08:40 +11:00
Dylan Lom 0a8fc0c0ee (#4) Add link and variable to header example
* Add sh_prefix variable to be used soon TM
* Rename header_list_to_html to header_list_process
* Move macros so they wrap the functions that use them
2021-01-26 17:56:15 +11:00
Dylan Lom 74b0e7aa54 Fix bug with link elements
Link tags in the header were using "vals=" instead of "href="...
2021-01-26 13:01:39 +11:00
Dylan Lom c77375a636
Merge pull request #3 from dylan-lom/#2
(#2) Implement header section
2021-01-21 11:55:42 +11:00
Dylan Lom 2b0eb5eaaf (#2) Convert header_isend to macro
* I think this is actually a pretty good use-case for a macro, the
  overhead of the function (in terms of readability and stack stuff i
  guess) seems overkill for what it was doing.
2021-01-21 11:52:34 +11:00
Dylan Lom 0c9edfacaf (#2) Capitalise macros
* #undef the nasty macro for converting to HTML
2021-01-21 11:42:29 +11:00
Dylan Lom 9ed8f8f190 (#2) Add shmd header file
Start documenting some of the functions
2021-01-21 11:24:01 +11:00
Dylan Lom 208b5f9c9c (#2) MVP header parsing implementation
* examples/header.shmd can now be successfully parsed
* However, some clean-up is probably required before this should be
  merged.
* Add a command to examples/header.shmd to make sure that the body is
  still parsed correctly after the header.
2021-01-16 20:38:53 +11:00
Dylan Lom 98208b511b (#2) Add str_list_free utility function 2021-01-16 20:38:13 +11:00
Dylan Lom 4cc793fcda (#2) Implement header_list_to_html function
It converts a str_list into a html tag based on the rules set out in
issue #2.

Fix issue with header_split function where quotes weren't being skipped
(e.g. they were included in the output).

Fix issue with header_split function where the last word wasn't being
included.
2021-01-16 19:58:03 +11:00
Dylan Lom 66edc8f6fd (#2) Implement header_split function
This splits a string into individual words, seperated by a space and
optionally quoted.
2021-01-16 16:49:08 +11:00
Dylan Lom 8752661e75 (#2) Add realloc_amount argument to str_pushc
* Add TODO's to top of util.h
2021-01-16 16:45:08 +11:00
Dylan Lom e4b831ede8 (#2) Add str_pushc utility function
* Return number of trimmed char's from `str_trimr`, instead of modified
  string.
* Re-order util.h based on #include convention (function name length,
  then alphabetical). Re-order util.c to match
2021-01-16 16:27:52 +11:00
Dylan Lom 4c107fa48a (#2) Add str_list to utils, add header example
* Dynamically allocated list of strings, this is useful for parsing
  header component.
* Add header example from issue #2
2021-01-16 16:14:52 +11:00
Dylan Lom e6c6a589f8 Add calloc-helper functions
* Add `ecalloc` function which calls die if calloc returns NULL
* Add `str_malloc` macro-function which calls calloc with size as
  sizeof(char)
* Add `str_ealloc` macro-function which calls ecalloc with size as
  sizeof(char)
2021-01-16 14:40:16 +11:00
Dylan Lom a44252d21a Rename variable fp to pp in command_execute
This makes it clearer the it is a pipe being read, not a file and
distinguishes it from fp, which is being used elsewhere to mean the
source of incoming shmd (e.g. stdin).
2021-01-16 14:20:29 +11:00
Dylan Lom 6d11dd1fb8
Merge pull request #1 from dylan-lom/pre-alpha
v0.0.1
2021-01-16 01:50:55 +11:00
Dylan Lom 09474ef27d Add extra examples
Test should probably live in it's own directory but it's fine in
examples for now
2021-01-16 01:48:36 +11:00
Dylan Lom 3a614a7f53 Remove echo dependency
The shmd program now interprets the $(...) command substitution on it's
own. This means that basic.shmd now compiles correctly!

`execute_command` has been renamed to `command_execute` to match the
naming of `command_substitute`. It also now strips up to one trailing
newline from the command's output.
2021-01-16 01:45:26 +11:00
Dylan Lom d57b7098d6 Add str_trimr utility function 2021-01-16 01:45:11 +11:00
Dylan Lom 09a4f8594b Add example with pipe in command 2021-01-15 22:20:32 +11:00
Dylan Lom cbe85c2cff Basic implementation using echo command
I feel quite dumb realising I could've just made this a shell
one-liner... although from a bit of playing I couldn't actually get echo
"$(cat)" to execute command substitution from the input properly.

Still can't compile examples/basic.shmd as the backquotes (`) are being
interpreted by the shell, the same would be true of anything in
paranethesis, which would be executed in a subshell.

Quotes aren't as damaging as I thought they would be (no errors), but
double quotes outside of commands are swallowed, see additions to
examples/basic.shmd

I'd also like to do some environment stuff at a later date, so eh maybe
I'll keep doing it in C... I've been enjoying it more than I would've a
shell script also.
2021-01-15 22:06:15 +11:00
Dylan Lom 54c68e36ef Unify style
* Local #includes last, includes ordered by line length, then
  alphabetically
* Snake case for variables
* Use more descriptive name, `str_concat`, for `concat` function
2021-01-15 19:38:12 +11:00
Dylan Lom 2f8f675cfb Add build script, shmd and util
Current functionality
* Executing a compile-time hardcoded command
2021-01-14 22:48:35 +11:00
Dylan Lom 7e0b7afb59 Add a basic example and gitignore 2021-01-14 22:44:44 +11:00
Dylan Lom 01b49c8e58 Add README.md 2021-01-14 22:43:32 +11:00