Skip to content

Commit

Permalink
Interaction and tokenizer are the same.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirko Boehm (Endocode) committed Jul 6, 2018
1 parent 3339423 commit e731ac0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package interaction
package tokenizer

// This file is part of shelldoc.
// © 2018, Mirko Boehm <[email protected]> and the shelldoc contributors
Expand Down
11 changes: 5 additions & 6 deletions pkg/tokenizer/tokenizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"regexp"
"strings"

"github.com/endocode/shelldoc/pkg/interaction"
"gopkg.in/russross/blackfriday.v2"
)

Expand All @@ -20,7 +19,7 @@ type Visitor struct {
// FencedCodeBlock should be assigned a function to be called when a fenced code block is encountered
FencedCodeBlock func(visitor *Visitor, node *blackfriday.Node) blackfriday.WalkStatus
// After parsing, Interactions will hold the shell interactions found in the file
Interactions []*interaction.Interaction
Interactions []*Interaction
}

const cmdEx = "^[\\$>]\\s+(.+)$"
Expand All @@ -30,7 +29,7 @@ func handleCodeBlock(visitor *Visitor, node *blackfriday.Node) blackfriday.WalkS
cmdRx := regexp.MustCompile(cmdEx)

lines := strings.Split(string(node.Literal), "\n")
var current *interaction.Interaction
var current *Interaction
for _, line := range lines {
line = strings.TrimSpace(line)
if len(line) == 0 {
Expand All @@ -39,7 +38,7 @@ func handleCodeBlock(visitor *Visitor, node *blackfriday.Node) blackfriday.WalkS
match := cmdRx.FindStringSubmatch(line)
if len(match) > 1 {
// begin a new command
current = new(interaction.Interaction)
current = new(Interaction)
visitor.Interactions = append(visitor.Interactions, current)
cmd := match[1]
current.Cmd = cmd
Expand Down Expand Up @@ -110,7 +109,7 @@ func handleFencedCodeBlock(visitor *Visitor, node *blackfriday.Node) blackfriday
// closer := lines[len(lines)-1] // closer is not parsed any further
lines = lines[1 : len(lines)-1]

var current *interaction.Interaction
var current *Interaction
for _, line := range lines {
line = strings.TrimSpace(line)
if len(line) == 0 {
Expand All @@ -119,7 +118,7 @@ func handleFencedCodeBlock(visitor *Visitor, node *blackfriday.Node) blackfriday
match := cmdRx.FindStringSubmatch(line)
if len(match) > 1 {
// begin a new command
current = new(interaction.Interaction)
current = new(Interaction)
current.Language = language
current.Attributes = attributes
visitor.Interactions = append(visitor.Interactions, current)
Expand Down

0 comments on commit e731ac0

Please sign in to comment.