mirror of
				https://github.com/osmarks/mycorrhiza.git
				synced 2025-10-31 15:43:00 +00:00 
			
		
		
		
	Do nothing in particular
This commit is contained in:
		| @@ -3,7 +3,6 @@ package markup | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"html" | ||||
| 	"regexp" | ||||
| 	"strings" | ||||
|  | ||||
| @@ -43,7 +42,7 @@ func (md *MycoDoc) Lex(recursionLevel int) *MycoDoc { | ||||
| 	return md | ||||
| } | ||||
|  | ||||
| // AsHtml returns an html representation of the document | ||||
| // AsHTML returns an html representation of the document | ||||
| func (md *MycoDoc) AsHTML() string { | ||||
| 	md.html = Parse(md.Lex(0).ast, 0, 0, 0) | ||||
| 	return md.html | ||||
| @@ -97,76 +96,3 @@ func (md *MycoDoc) ogFillVars() *MycoDoc { | ||||
| func ogTag(property, content string) string { | ||||
| 	return fmt.Sprintf(`<meta property="og:%s" content="%s"/>`, property, content) | ||||
| } | ||||
|  | ||||
| /* The rest of this file is currently unused. TODO: use it I guess */ | ||||
|  | ||||
| type BlockType int | ||||
|  | ||||
| const ( | ||||
| 	BlockH1 = iota | ||||
| 	BlockH2 | ||||
| 	BlockH3 | ||||
| 	BlockH4 | ||||
| 	BlockH5 | ||||
| 	BlockH6 | ||||
| 	BlockRocket | ||||
| 	BlockPre | ||||
| 	BlockQuote | ||||
| 	BlockPara | ||||
| ) | ||||
|  | ||||
| type CrawlWhere int | ||||
|  | ||||
| const ( | ||||
| 	inSomewhere = iota | ||||
| 	inPre | ||||
| 	inEnd | ||||
| ) | ||||
|  | ||||
| func crawl(name, content string) []string { | ||||
| 	stateStack := []CrawlWhere{inSomewhere} | ||||
|  | ||||
| 	startsWith := func(token string) bool { | ||||
| 		return strings.HasPrefix(content, token) | ||||
| 	} | ||||
|  | ||||
| 	pop := func() { | ||||
| 		stateStack = stateStack[:len(stateStack)-1] | ||||
| 	} | ||||
|  | ||||
| 	push := func(s CrawlWhere) { | ||||
| 		stateStack = append(stateStack, s) | ||||
| 	} | ||||
|  | ||||
| 	readln := func(c string) (string, string) { | ||||
| 		parts := strings.SplitN(c, "\n", 1) | ||||
| 		return parts[0], parts[1] | ||||
| 	} | ||||
|  | ||||
| 	preAcc := "" | ||||
| 	line := "" | ||||
|  | ||||
| 	for { | ||||
| 		switch stateStack[0] { | ||||
| 		case inSomewhere: | ||||
| 			switch { | ||||
| 			case startsWith("```"): | ||||
| 				push(inPre) | ||||
| 				_, content = readln(content) | ||||
| 			default: | ||||
| 			} | ||||
| 		case inPre: | ||||
| 			switch { | ||||
| 			case startsWith("```"): | ||||
| 				pop() | ||||
| 				_, content = readln(content) | ||||
| 			default: | ||||
| 				line, content = readln(content) | ||||
| 				preAcc += html.EscapeString(line) | ||||
| 			} | ||||
| 		} | ||||
| 		break | ||||
| 	} | ||||
|  | ||||
| 	return []string{} | ||||
| } | ||||
|   | ||||
| @@ -10,14 +10,3 @@ func remover(prefix string) func(string) string { | ||||
| 		return strings.TrimSpace(strings.TrimPrefix(l, prefix)) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Remove #, ## or ### from beginning of `line`. | ||||
| func removeHeadingOctothorps(line string) string { | ||||
| 	f := remover("#") | ||||
| 	return f(f(f(line))) | ||||
| } | ||||
|  | ||||
| // Return a canonical representation of a hypha `name`. | ||||
| func canonicalName(name string) string { | ||||
| 	return strings.ToLower(strings.ReplaceAll(strings.TrimSpace(name), " ", "_")) | ||||
| } | ||||
|   | ||||
| @@ -2,6 +2,7 @@ package markup | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"github.com/bouncepaw/mycorrhiza/util" | ||||
| 	"path" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| @@ -67,11 +68,11 @@ func parseTransclusion(line, hyphaName string) (xclusion Transclusion) { | ||||
| func xclCanonicalName(hyphaName, xclName string) string { | ||||
| 	switch { | ||||
| 	case strings.HasPrefix(xclName, "./"): | ||||
| 		return canonicalName(path.Join(hyphaName, strings.TrimPrefix(xclName, "./"))) | ||||
| 		return util.CanonicalName(path.Join(hyphaName, strings.TrimPrefix(xclName, "./"))) | ||||
| 	case strings.HasPrefix(xclName, "../"): | ||||
| 		return canonicalName(path.Join(path.Dir(hyphaName), strings.TrimPrefix(xclName, "../"))) | ||||
| 		return util.CanonicalName(path.Join(path.Dir(hyphaName), strings.TrimPrefix(xclName, "../"))) | ||||
| 	default: | ||||
| 		return canonicalName(xclName) | ||||
| 		return util.CanonicalName(xclName) | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Timur Ismagilov
					Timur Ismagilov