2022-11-08 16:13:58 +01:00
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
2022-11-27 19:20:29 +01:00
|
|
|
// SPDX-License-Identifier: MIT
|
2022-11-08 16:13:58 +01:00
|
|
|
|
|
|
|
package html
|
|
|
|
|
|
|
|
// ParseSizeAndClass get size and class from string with default values
|
|
|
|
// If present, "others" expects the new size first and then the classes to use
|
2023-07-04 20:36:08 +02:00
|
|
|
func ParseSizeAndClass(defaultSize int, defaultClass string, others ...any) (int, string) {
|
2022-11-08 16:13:58 +01:00
|
|
|
size := defaultSize
|
2023-08-05 06:34:59 +02:00
|
|
|
if len(others) >= 1 {
|
|
|
|
if v, ok := others[0].(int); ok && v != 0 {
|
|
|
|
size = v
|
|
|
|
}
|
2022-11-08 16:13:58 +01:00
|
|
|
}
|
|
|
|
class := defaultClass
|
2023-08-05 06:34:59 +02:00
|
|
|
if len(others) >= 2 {
|
|
|
|
if v, ok := others[1].(string); ok && v != "" {
|
|
|
|
if class != "" {
|
|
|
|
class += " "
|
|
|
|
}
|
|
|
|
class += v
|
2022-11-08 16:13:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return size, class
|
|
|
|
}
|