Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/vendor/github.com/frustra/bbcode/bbcode.go
akuma06 ed61de6276 Add bbcode support (#1433)
* Add bbcode support

Closes #687
As the issue suggested, I added bbcodes support to the forms.
Now we support basic bbcodes, markdown and html tags

* Add new dependencies
2017-08-29 09:56:44 +10:00

42 lignes
747 o
Go

// Copyright 2015 Frustra. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
// Package bbcode implements a parser and HTML generator for BBCode.
package bbcode
import "sort"
type BBOpeningTag struct {
Name string
Value string
Args map[string]string
Raw string
}
type BBClosingTag struct {
Name string
Raw string
}
func (t *BBOpeningTag) String() string {
str := t.Name
if len(t.Value) > 0 {
str += "=" + t.Value
}
keys := make([]string, len(t.Args))
i := 0
for key := range t.Args {
keys[i] = key
i++
}
sort.Strings(keys)
for _, key := range keys {
v := t.Args[key]
str += " " + key
if len(v) > 0 {
str += "=" + v
}
}
return str
}